diff options
Diffstat (limited to '2026/games_submissions/crm148/game.js')
| -rw-r--r-- | 2026/games_submissions/crm148/game.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/2026/games_submissions/crm148/game.js b/2026/games_submissions/crm148/game.js new file mode 100644 index 0000000..00f1cc6 --- /dev/null +++ b/2026/games_submissions/crm148/game.js @@ -0,0 +1,101 @@ + +import { View, globalView } from './view.js'; +import { getCosmos } from './cosmos.js'; +import Vec2 from './vec2.js'; + +import { victory, death, initInput, getDebugInfo } from './control.js'; + +startButton.onclick = function (ev) { + window.postMessage({op:"start", difficulty: 1}); +} + +plusButton.onclick = function(ev) { + window.testAngle += 0.1; +} + +minusButton.onclick = function(ev) { + window.testAngle -= 0.1; +} + +testButton.onclick = function (ev) { + if (!cosmos) { + cosmos = getCosmos(); + cosmos.init(1); + initInput(cosmos); + } + + cosmos.running = false; + cosmos.player.state = 'start_testing'; + + cosmos.pulses = [ + new Pulse(Math.PI / 4, Math.PI, 70, 0, 30), + ]; + + cosmos.update(0); + cosmos.render(); + + // if (!cosmos.running) { + // if (lasttime === undefined) { + // render(0); + // lasttime = undefined; + // starttime = undefined; + // } else { + // render(lasttime); + // } + // } +} + +var cosmos; + +function start(difficulty) { + cosmos = getCosmos(); + cosmos.init(difficulty); + initInput(cosmos); + + window.requestAnimationFrame(render); + // TODO: set up mouse input listener, remove it on game over + window.parent.postMessage({op: "started", verb: "dodge!"}); +} + +// input - mouse click +// point the ship and thrust +// add particle (time, position, velocity) +// expire the particles - maybe wait until all of them are over time limit so +// new ones keep the old ones alive +// fade to black and keep it there +// smoke on the grey background of space + +// TODO: game is over after some amount of energy (increases with difficulty) is +// expelled from the star +function nop() { + ; +} + +var starttime; +var lasttime; +// var start = startGame; + +function render(timestamp) { + if (starttime === undefined) { + starttime = timestamp; + lasttime = starttime; + } else { + nop(); + } + // const elapsed = timestamp - starttime; + const dt = (timestamp - lasttime) / 1000.0; + cosmos.update(dt); + cosmos.render(); + lasttime = timestamp; + if (cosmos.running) { + window.requestAnimationFrame(render); + } else { + // console.log('over'); + } +} + + +export { + start, +} + |
