From c4e88954647d876b1a2108393ee5a4a482a75386 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Fri, 23 Aug 2024 14:52:04 -0700 Subject: [PATCH] improved terrain --- TODO.txt | 9 +++++--- src/client/graphics/GameRenderer.ts | 8 ------- src/core/configuration/PastelTheme.ts | 26 ++++++++++++++++------- src/core/execution/BoatAttackExecution.ts | 8 +++---- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/TODO.txt b/TODO.txt index 5d6f474cf..eb8ec8bc5 100644 --- a/TODO.txt +++ b/TODO.txt @@ -38,13 +38,16 @@ * boats same color as owner DONE 8/19/2024 * make coasts look better DONE 8/22/2024 * only put imageDataOnce, draw territories on top DONE 8/23/2024 -* have boats not get close to shore +* have boats not get close to shore DONE 8/23/2024 +* improve terrain colors +* try vintage theme * BUG: boat doesn't work if on lake if other player not on same lake * Allow boats to attack TerraNullius * add shader to dim border * remove player.info() -* fix enemy islands when attacking -* BUG: ocean is considered TerraNullius +* improve menu +* give time to (re) spawn at start of game +* BUG: ocean is considered TerraNullius ? * BUG: fix hotreload (priority queue breaks it) * PERF: use hierarchical a* search for boats * Add terrain elevation to map \ No newline at end of file diff --git a/src/client/graphics/GameRenderer.ts b/src/client/graphics/GameRenderer.ts index d06982ced..3613a929b 100644 --- a/src/client/graphics/GameRenderer.ts +++ b/src/client/graphics/GameRenderer.ts @@ -134,14 +134,6 @@ export class GameRenderer { } tick() { - // Create a temporary canvas for the game content - // this.tempCanvas = document.createElement('canvas'); - // const tempCtx = this.tempCanvas.getContext('2d'); - // this.tempCanvas.width = this.gs.width(); - // this.tempCanvas.height = this.gs.height(); - - // // Put the ImageData on the temp canvas - // tempCtx.putImageData(this.imageData, 0, 0); this.nameRenderer.tick() } diff --git a/src/core/configuration/PastelTheme.ts b/src/core/configuration/PastelTheme.ts index f9ed8999e..4a3dd7bd8 100644 --- a/src/core/configuration/PastelTheme.ts +++ b/src/core/configuration/PastelTheme.ts @@ -1,9 +1,12 @@ -import {Colord, colord} from "colord"; +import {Colord, colord, random} from "colord"; import {PlayerID, Tile} from "../Game"; import {Theme} from "./Config"; import {time} from "console"; +import {PseudoRandom} from "../PseudoRandom"; export const pastelTheme = new class implements Theme { + private rand = new PseudoRandom(123) + private background = colord({r: 100, g: 100, b: 100}); private land = colord({r: 244, g: 243, b: 198}); private shore = colord({r: 234, g: 343, b: 188}); @@ -87,15 +90,22 @@ export const pastelTheme = new class implements Theme { } return this.land; } else { + const w = this.water.rgba if (tile.isShorelineWater()) { - return this.shorelineWater + return colord({ + r: Math.max(w.r + 10, 0), + g: Math.max(w.g + 10, 0), + b: Math.max(w.b + 10, 0) + }) } - return colord({ - r: Math.min(20, 255), - g: Math.min(20, 255), - b: Math.min(20 + tile.magnitude(), 255) - }) - return this.water; + if (tile.magnitude() < 5) { + return colord({ + r: Math.max(w.r + 5 - tile.magnitude() / 2, 0), + g: Math.max(w.g + 5 - tile.magnitude() / 2, 0), + b: Math.max(w.b + 5 - tile.magnitude() / 2, 0) + }) + } + return this.water } } diff --git a/src/core/execution/BoatAttackExecution.ts b/src/core/execution/BoatAttackExecution.ts index 87d3010fd..9bb0bb2c4 100644 --- a/src/core/execution/BoatAttackExecution.ts +++ b/src/core/execution/BoatAttackExecution.ts @@ -1,5 +1,5 @@ import PriorityQueue from "priority-queue-typescript"; -import {Boat, Cell, Execution, MutableBoat, MutableGame, MutablePlayer, Player, PlayerID, Tile} from "../Game"; +import {Boat, Cell, Execution, MutableBoat, MutableGame, MutablePlayer, Player, PlayerID, Tile, TileEvent} from "../Game"; import {manhattanDist} from "../Util"; import {AttackExecution} from "./AttackExecution"; import {Config, PlayerConfig} from "../configuration/Config"; @@ -60,7 +60,7 @@ export class BoatAttackExecution implements Execution { return } this.aStarPre = new AStar(this.src, this.dst) - this.aStarPre.compute(10) + this.aStarPre.compute(100) this.path = this.aStarPre.reconstructPath() if (this.path != null) { console.log(`got path ${this.path.map(t => t.cell().toString())}`) @@ -81,7 +81,7 @@ export class BoatAttackExecution implements Execution { } this.lastMove = ticks - if (!this.finalPath && this.aStarComplete.compute(10000)) { + if (!this.finalPath && this.aStarComplete.compute(30000)) { this.path.push(...this.aStarComplete.reconstructPath()) this.finalPath = true } @@ -167,7 +167,7 @@ export class AStar { for (const neighbor of this.current.neighbors()) { if (neighbor != this.dst && neighbor.isLand()) continue; // Skip non-water tiles - const tentativeGScore = this.gScore.get(this.current)! + 1; // Assuming uniform cost + const tentativeGScore = this.gScore.get(this.current)! + 100 - neighbor.magnitude(); if (!this.gScore.has(neighbor) || tentativeGScore < this.gScore.get(neighbor)!) { this.cameFrom.set(neighbor, this.current);