Change black empty tile to grass and make it destructable

This commit is contained in:
Peter Stockings
2026-01-05 20:59:33 +11:00
parent a7091c70c6
commit ecf58dded1
8 changed files with 150 additions and 43 deletions

49
src/core/terrain.ts Normal file
View File

@@ -0,0 +1,49 @@
export const TileType = {
EMPTY: 1,
WALL: 4,
GRASS: 15,
EMPTY_DECO: 24,
WALL_DECO: 12,
EXIT: 8,
WATER: 63 // Unused but kept for safety/legacy
} as const;
export type TileType = typeof TileType[keyof typeof TileType];
export interface TileBehavior {
id: TileType;
isBlocking: boolean;
isDestructible: boolean;
isDestructibleByWalk?: boolean;
destructsTo?: TileType;
}
export const TILE_DEFINITIONS: Record<number, TileBehavior> = {
[TileType.EMPTY]: { id: TileType.EMPTY, isBlocking: false, isDestructible: false },
[TileType.WALL]: { id: TileType.WALL, isBlocking: true, isDestructible: false },
[TileType.GRASS]: { id: TileType.GRASS, isBlocking: false, isDestructible: true, isDestructibleByWalk: true, destructsTo: TileType.EMPTY },
[TileType.EMPTY_DECO]: { id: TileType.EMPTY_DECO, isBlocking: false, isDestructible: false },
[TileType.WALL_DECO]: { id: TileType.WALL_DECO, isBlocking: true, isDestructible: false },
[TileType.EXIT]: { id: TileType.EXIT, isBlocking: false, isDestructible: false },
[TileType.WATER]: { id: TileType.WATER, isBlocking: true, isDestructible: false }
};
export function isBlocking(tile: number): boolean {
const def = TILE_DEFINITIONS[tile];
return def ? def.isBlocking : false;
}
export function isDestructible(tile: number): boolean {
const def = TILE_DEFINITIONS[tile];
return def ? def.isDestructible : false;
}
export function isDestructibleByWalk(tile: number): boolean {
const def = TILE_DEFINITIONS[tile];
return def ? !!def.isDestructibleByWalk : false;
}
export function getDestructionResult(tile: number): number | undefined {
const def = TILE_DEFINITIONS[tile];
return def ? def.destructsTo : undefined;
}