mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:50:45 +00:00
create binary repr of map
This commit is contained in:
@@ -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
|
||||
* PERF: use hierarchical a* search for boats
|
||||
* Add terrain elevation to map
|
||||
Binary file not shown.
@@ -42,6 +42,7 @@ export interface Tile {
|
||||
isShore(): boolean
|
||||
isWater(): boolean
|
||||
isShorelineWater(): boolean
|
||||
magnitude(): number
|
||||
owner(): Player | TerraNullius
|
||||
hasOwner(): boolean
|
||||
isBorder(): boolean
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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[][]) { }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class Terrain {
|
||||
}
|
||||
|
||||
export async function loadTerrainMap(): Promise<void> {
|
||||
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<void> {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user