diff --git a/TODO.txt b/TODO.txt index 1324cbccd..13d5ebf39 100644 --- a/TODO.txt +++ b/TODO.txt @@ -37,6 +37,7 @@ * make boats larger DONE 8/19/2024 * boats same color as owner DONE 8/19/2024 * make coasts look better DONE 8/22/2024 +* only put imageDataOnce, draw territories on top * have boats not get close to shore * BUG: boat doesn't work if on lake if other player not on same lake * Allow boats to attack TerraNullius @@ -45,4 +46,5 @@ * fix enemy islands when attacking * BUG: ocean is considered TerraNullius * BUG: fix hotreload (priority queue breaks it) -* PERF: use hierarchical a* search for boats \ No newline at end of file +* PERF: use hierarchical a* search for boats +* Add terrain elevation to map \ No newline at end of file diff --git a/resources/World.bin b/resources/World.bin new file mode 100644 index 000000000..07e2b70d7 Binary files /dev/null and b/resources/World.bin differ diff --git a/src/core/Game.ts b/src/core/Game.ts index a8de0cfe1..0221b50b9 100644 --- a/src/core/Game.ts +++ b/src/core/Game.ts @@ -42,6 +42,7 @@ export interface Tile { isShore(): boolean isWater(): boolean isShorelineWater(): boolean + magnitude(): number owner(): Player | TerraNullius hasOwner(): boolean isBorder(): boolean diff --git a/src/core/GameImpl.ts b/src/core/GameImpl.ts index 15817f3e2..0284698c0 100644 --- a/src/core/GameImpl.ts +++ b/src/core/GameImpl.ts @@ -19,6 +19,9 @@ class TileImpl implements Tile { private readonly _cell: Cell, private readonly _terrain: Terrain ) { } + magnitude(): number { + return this._terrain.magnitude + } isShore(): boolean { return this.isLand() && this._terrain.shoreline } diff --git a/src/core/TerrainMapLoader.ts b/src/core/TerrainMapLoader.ts index 561d69a5c..dc26b83e0 100644 --- a/src/core/TerrainMapLoader.ts +++ b/src/core/TerrainMapLoader.ts @@ -1,5 +1,5 @@ import {Cell} from './Game'; -import binAsString from "!!binary-loader!../../resources/WorldSmall.bin"; +import binAsString from "!!binary-loader!../../resources/World.bin"; export class TerrainMap { constructor(public readonly tiles: Terrain[][]) { } diff --git a/src/core/configuration/PastelTheme.ts b/src/core/configuration/PastelTheme.ts index 3c9774e1e..f9ed8999e 100644 --- a/src/core/configuration/PastelTheme.ts +++ b/src/core/configuration/PastelTheme.ts @@ -1,6 +1,7 @@ import {Colord, colord} from "colord"; import {PlayerID, Tile} from "../Game"; import {Theme} from "./Config"; +import {time} from "console"; export const pastelTheme = new class implements Theme { private background = colord({r: 100, g: 100, b: 100}); @@ -89,6 +90,11 @@ export const pastelTheme = new class implements Theme { if (tile.isShorelineWater()) { return this.shorelineWater } + return colord({ + r: Math.min(20, 255), + g: Math.min(20, 255), + b: Math.min(20 + tile.magnitude(), 255) + }) return this.water; } } diff --git a/src/scripts/TerrainMapGenerator.ts b/src/scripts/TerrainMapGenerator.ts index f95a196ee..b0579bdc9 100644 --- a/src/scripts/TerrainMapGenerator.ts +++ b/src/scripts/TerrainMapGenerator.ts @@ -43,7 +43,7 @@ export class Terrain { } export async function loadTerrainMap(): Promise { - const imagePath = path.resolve(__dirname, '..', '..', 'resources', 'maps', 'WorldSmall.png'); + const imagePath = path.resolve(__dirname, '..', '..', 'resources', 'maps', 'World.png'); const readStream = createReadStream(imagePath); const img = await PImage.decodePNGFromStream(readStream); @@ -71,7 +71,7 @@ export async function loadTerrainMap(): Promise { const shorelineWaters = processShore(terrain) processDistToLand(shorelineWaters, terrain) const packed = packTerrain(terrain) - const outputPath = path.join(__dirname, '..', '..', 'resources', 'WorldSmall.bin'); + const outputPath = path.join(__dirname, '..', '..', 'resources', 'World.bin'); fs.writeFile(outputPath, packed); } @@ -163,7 +163,7 @@ function packTerrain(map: Terrain[][]): Uint8Array { if (terrain.shoreline) { packedByte |= 0b01000000; } - packedByte |= Math.min(terrain.magnitude, 63); + packedByte |= Math.min(Math.ceil(terrain.magnitude / 2), 63); packedData[4 + y * width + x] = packedByte; }