Initial commit: Orbiter Game
Interactive 2D orbital flight simulator (HTML/CSS/JS, no dependencies). Newtonian gravity with RK4 integration, three scenarios (Surface Launch, Low Orbit, Station Rendezvous), trajectory prediction, camera/zoom, keyboard + touch controls, and automated unit + smoke tests.
This commit is contained in:
commit
b926fa2a78
11 files changed
+2337
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Orbital Flight Simulator - boot.
|
||||
* Wires renderer, UI, game and controls together and starts the RAF loop.
|
||||
* In Node (smoke test) boot() is exported and driven manually.
|
||||
*/
|
||||
(function (global) {
|
||||
'use strict';
|
||||
|
||||
function boot() {
|
||||
var canvas = document.getElementById('game');
|
||||
var renderer = new global.Renderer(canvas);
|
||||
var game = new global.Game(renderer, null);
|
||||
var ui = new global.UI(game);
|
||||
game.ui = ui;
|
||||
var controls = new global.Controls();
|
||||
game.controls = controls;
|
||||
controls.attach(game, ui);
|
||||
|
||||
// start on the menu; ship is null until a scenario is chosen
|
||||
ui.showMenu();
|
||||
|
||||
var coarse = global.matchMedia && global.matchMedia('(pointer: coarse)').matches;
|
||||
var touch = document.getElementById('touch-controls');
|
||||
if (touch) touch.classList.toggle('hidden', !coarse);
|
||||
|
||||
global.requestAnimationFrame(game.frame);
|
||||
|
||||
return { renderer: renderer, game: game, ui: ui, controls: controls };
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = { boot: boot };
|
||||
}
|
||||
global.BootOrbitalSim = boot;
|
||||
|
||||
// Auto-start in a real browser (skipped under the Node smoke test).
|
||||
if (typeof window !== 'undefined' && !global.__nodeSmoke) {
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', boot);
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
}
|
||||
})(typeof window !== 'undefined' ? window : globalThis);
|
||||
Reference in new issue
Block a user