initial: dungeon crawler with Bun + TypeScript modular architecture
- 19 TypeScript modules under src/ (constants, entities, room, game, render) - Canvas 2D rendering with dark fantasy palette - Room-based navigation, random 7x7 map generation - Two combat modes: ranged (pistol) and melee (knife) - Wall collision with door opening support - Minimap, HP bar, enemy AI - Bun build pipeline: src/main.ts -> dist/main.js + dist/index.html
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { RoomType, Doors } from '../types';
|
||||
import { buildTiles } from './tiles';
|
||||
import { Enemy } from '../entities/Enemy';
|
||||
import { Tear } from '../entities/Tear';
|
||||
|
||||
export class Room {
|
||||
c: number;
|
||||
r: number;
|
||||
type: RoomType;
|
||||
doors: Doors = { up: false, down: false, left: false, right: false };
|
||||
visited = false;
|
||||
cleared = false;
|
||||
enemies: Enemy[] = [];
|
||||
tears: Tear[] = [];
|
||||
tiles: number[][];
|
||||
|
||||
constructor(c: number, r: number, type: RoomType) {
|
||||
this.c = c;
|
||||
this.r = r;
|
||||
this.type = type;
|
||||
this.tiles = buildTiles();
|
||||
}
|
||||
|
||||
/** Rebuild base tiles and optionally place doors if cleared */
|
||||
buildTiles(): void {
|
||||
this.tiles = buildTiles(this.cleared || this.type === 'spawn' ? this.doors : undefined);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user