moved TerrainMap

This commit is contained in:
evanpelle
2024-08-21 20:02:59 -07:00
parent 5e7c206f0d
commit af65810413
2 changed files with 18 additions and 24 deletions
-16
View File
@@ -190,22 +190,6 @@ class TerraNulliusImpl implements TerraNullius {
}
export class TerrainMapImpl implements TerrainMap {
constructor(public readonly tiles: TerrainType[][]) { }
terrain(cell: Cell): TerrainType {
return this.tiles[cell.x][cell.y]
}
width(): number {
return this.tiles.length
}
height(): number {
return this.tiles[0].length
}
}
export class GameImpl implements MutableGame {
private ticks = 0
+18 -8
View File
@@ -1,12 +1,28 @@
import {Jimp as JimpType, JimpConstructors} from '@jimp/core';
import 'jimp';
import {TerrainMapImpl} from './GameImpl';
import {TerrainTile} from '../../generated/protos';
import {Cell} from './Game';
declare const Jimp: JimpType & JimpConstructors;
export class TerrainMap {
constructor(public readonly tiles: TerrainType[][]) { }
terrain(cell: Cell): TerrainType {
return this.tiles[cell.x][cell.y]
}
width(): number {
return this.tiles.length
}
height(): number {
return this.tiles[0].length
}
}
// TODO: make terrain api better.
export class Terrain {
constructor(
@@ -22,12 +38,6 @@ export const TerrainTypes = {
Water: new Terrain(0, 0)
}
export interface TerrainMap {
terrain(cell: Cell): Terrain
width(): number
height(): number
}
export async function loadTerrainMap(): Promise<TerrainMap> {
const imageModule = await import(`../../resources/maps/World.png`);
const imageUrl = imageModule.default;
@@ -45,5 +55,5 @@ export async function loadTerrainMap(): Promise<TerrainMap> {
}
})
return new TerrainMapImpl(terrain);
return new TerrainMap(terrain);
}