summaryrefslogtreecommitdiff
path: root/2026/games_submissions/crm148/cosmos.js
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-08-29 04:06:51 -0400
committerLLLL Colonq <llll@colonq>2026-08-29 04:06:51 -0400
commit761a3172bf4c15aed3836e4d1cd6f815b651b0e0 (patch)
treecc90491529e83349d84d42a8e9982e5f0f38338e /2026/games_submissions/crm148/cosmos.js
parent0d2d8cd897e94bd94e0b3ae7c6ce9aa580a44a0a (diff)
Fix
Diffstat (limited to '2026/games_submissions/crm148/cosmos.js')
-rw-r--r--2026/games_submissions/crm148/cosmos.js109
1 files changed, 0 insertions, 109 deletions
diff --git a/2026/games_submissions/crm148/cosmos.js b/2026/games_submissions/crm148/cosmos.js
deleted file mode 100644
index 0b14946..0000000
--- a/2026/games_submissions/crm148/cosmos.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import {
- victory,
- getDebugInfo,
- debugKey,
-} from './control.js';
-import Ship from './ship.js';
-import Star from './star.js';
-
-import Vec2 from './vec2.js';
-import { drawSquare } from './util.js';
-import { globalView } from './view.js';
-
-var view;
-
-class Cosmos {
- pulses = [];
- star;
- player;
- running;
-
- dissipated;
- dissipated_target;
- dissipated_target_base = 50;
-
- gravity = .008;
- thresh_crit = 5.00;
- max_size = (Math.min(gameCanvas.width, gameCanvas.height) / 2) + 100;
- pulse_min_str = 7;
- pulse_max_str = 20;
- pulse_vel_base = 70.0;
-
- angle = 1;
- omega = 1.0;
-
- init(difficulty) {
- view = globalView();
- const STRAD = 9;
- const DIFFMUL = 3;
- var starRadius = STRAD + difficulty * DIFFMUL;
- this.star = new Star(starRadius, difficulty);
- this.pulses = [];
- this.player = Ship.AboveRadius(starRadius, this.max_size);
- this.dissipated = 0;
- this.dissipated_target = this.dissipated_target_base + 1 * (difficulty * 1.2);
- this.omega = 1.0 + (0.2 * difficulty);
- this.running = true;
- }
-
- stop() {
- this.running = false;
- // console.log('stop the world');
- }
-
- dissipate(energy) {
- this.dissipated += energy;
- debugKey('dissipated', this.dissipated);
- }
-
- update(dt) {
- this.angle = (this.angle + this.omega * dt) % (2 * Math.PI);
- this.player.update(dt);
- this.star.update(dt);
- this.pulses.forEach((p) => p.update(dt));
- this.pulses = this.pulses.filter((p) => { return p.is_alive() });
- if (this.dissipated > this.dissipated_target) {
- victory();
- }
- }
-
- render() {
- ctx.fillStyle = "#151515";
- ctx.strokeStyle = "#eeeeee";
- ctx.fillRect(0,0, gameCanvas.width, gameCanvas.height);
- this.star.render(ctx);
- this.pulses.forEach((p) => p.render(ctx));
- this.player.render(ctx);
- // debugP.textContent = JSON.stringify(getDebugInfo());
-
- // this.renderSpin();
- }
-
- renderSpin() {
- ctx.fillStyle = "#ff1515";
- ctx.strokeStyle = "#ff1515";
- var p = view.project(new Vec2(Math.cos(this.angle),
- Math.sin(this.angle)).scale(this.star.radius + 5));
- drawSquare(ctx, p, 4);
- var center = view.project(Vec2.zero());
- var radius = center.sub(p).length();
-
- ctx.beginPath();
- ctx.arc(center.x, center.y, radius, -this.angle, -this.angle - 0.4, true);
- ctx.stroke();
- }
-}
-
-var theCosmos = new Cosmos();
-var ctx = gameCanvas.getContext("2d");
-
-window.cosmos = theCosmos;
-
-function getCosmos() {
- return theCosmos;
-}
-
-export {
- Cosmos,
- getCosmos,
-}