diff options
Diffstat (limited to 'html/space/game.js')
-rw-r--r-- | html/space/game.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/html/space/game.js b/html/space/game.js new file mode 100644 index 0000000..ecd7abc --- /dev/null +++ b/html/space/game.js @@ -0,0 +1,45 @@ +// Main game entry point +import { initRenderer, render } from './renderer.js'; +import { initInput, updateInput } from './input.js'; +import { initPhysics, updatePhysics } from './physics.js'; +import { initGameState, updateGameState } from './gameState.js'; + +// Game state +let lastTime = 0; +let isRunning = true; + +// Initialize all systems +function init() { + console.log('Initializing game...'); + initRenderer(); + initInput(); + initPhysics(); + initGameState(); + console.log('Game initialized'); +} + +// Main game loop using requestAnimationFrame +function gameLoop(timestamp) { + if (!isRunning) return; + + const deltaTime = timestamp - lastTime; + lastTime = timestamp; + + // Update game systems + updateInput(); + updatePhysics(deltaTime); + updateGameState(deltaTime); + render(); + + // Debug output + if (Math.random() < 0.01) { // Only log occasionally to avoid spam + console.log('Game loop running, deltaTime:', deltaTime); + } + + requestAnimationFrame(gameLoop); +} + +// Start the game +console.log('Starting game...'); +init(); +requestAnimationFrame(gameLoop); \ No newline at end of file |