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:
Volodia
2026-06-18 12:55:17 +03:00
commit b947fbb7fb
30 changed files with 2376 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { setupInput, KEYS } from './input';
import { Game } from './game/Game';
// Global key bindings (mode toggle, restart) handled here
setupInput();
window.addEventListener('keydown', (e: KeyboardEvent) => {
const game = (window as any).__game as Game | undefined;
if (!game) return;
// Toggle combat mode
if ((e.key === 'Tab' || e.key === 'q' || e.key === 'Q') && !game.gameOver && !game.won) {
e.preventDefault();
game.toggleMode();
}
// Restart
if (e.key === 'r' || e.key === 'R') {
if (game.gameOver || game.won) game.restart();
}
});
// Bootstrap
window.addEventListener('load', () => {
const canvas = document.getElementById('game') as HTMLCanvasElement;
if (!canvas) {
document.body.innerHTML = '<p style="color:red">Error: canvas element not found</p>';
return;
}
const game = new Game(canvas);
(window as any).__game = game;
});