diff options
| author | LLLL Colonq <llll@colonq> | 2026-08-04 04:35:44 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-08-04 04:35:44 -0400 |
| commit | 3c7796f066647090ed8436778bdfe25f11844c05 (patch) | |
| tree | 0644a101004d91af4fcdc2f51fcc2e03f7f255ce /2026/games_submissions/crm148/cosmos.js | |
| parent | a75221ab93f59d688f90cd83f0284ff98951fcfa (diff) | |
Prepare for upload
Diffstat (limited to '2026/games_submissions/crm148/cosmos.js')
| -rw-r--r-- | 2026/games_submissions/crm148/cosmos.js | 109 |
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, -} |
