feat: initialize project with core dependencies and game entry point

This commit is contained in:
2026-01-03 01:24:51 -05:00
commit 45d46ddac6
1382 changed files with 844553 additions and 0 deletions

52
src/Game.js Normal file
View File

@@ -0,0 +1,52 @@
import { Graphics } from './Graphics.js';
import { World } from './World.js';
import { Player } from './Player.js';
export class Game {
constructor() {
this.graphics = new Graphics();
this.world = new World(this.graphics.scene);
this.player = new Player(this.graphics.camera, this.world.colliders);
this.isRunning = false;
this.lastTime = 0;
this.setupUI();
}
setupUI() {
const startScreen = document.getElementById('start-screen');
const hud = document.getElementById('hud');
startScreen.addEventListener('click', () => {
this.player.lockControls();
startScreen.style.display = 'none';
hud.style.display = 'block';
this.isRunning = true;
});
}
start() {
this.graphics.init();
this.world.load();
// Add player to scene if needed, but usually player moves camera
this.graphics.scene.add(this.player.getObject());
requestAnimationFrame(this.loop.bind(this));
}
loop(time) {
requestAnimationFrame(this.loop.bind(this));
const dt = Math.min((time - this.lastTime) / 1000, 0.1); // Cap dt
this.lastTime = time;
if (this.isRunning) {
this.player.update(dt);
// this.world.update(dt);
}
this.graphics.render();
}
}