summaryrefslogtreecommitdiffstats
path: root/static/games/rms/state.js
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2026-07-25 14:38:15 -0700
committerRose Hogenson <rosehogenson@posteo.net>2026-07-25 14:38:15 -0700
commitd61d78acf999527bbc24798ac62a67b7eb17874a (patch)
tree280f7bf532b29886fb58a89bae1a29b9158d44a6 /static/games/rms/state.js
parentRename stallman-shooter to RMS shooter (diff)
downloadroseh.moe-d61d78acf999527bbc24798ac62a67b7eb17874a.tar.zst
Consolidate JS and sprites for fewer requests
Diffstat (limited to 'static/games/rms/state.js')
-rw-r--r--static/games/rms/state.js82
1 files changed, 0 insertions, 82 deletions
diff --git a/static/games/rms/state.js b/static/games/rms/state.js
deleted file mode 100644
index 0ec0586..0000000
--- a/static/games/rms/state.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import * as player from '/static/games/rms/player.js';
-import * as gates from '/static/games/rms/gates.js';
-import * as constants from '/static/games/rms/constants.js';
-
-export function straight_bullet_act(straight_bullet) {
- const x = straight_bullet.x;
- const d_x = straight_bullet.d_x;
- straight_bullet.x += d_x;
- const y = straight_bullet.y;
- const d_y = straight_bullet.d_y;
- straight_bullet.y += d_y;
-}
-
-export function straight_bullet_delete(straight_bullet) {
- straight_bullet.x = -1000; // LMAO
-}
-
-export class PBullet {
- constructor(x, d_x, y, d_y) {
- this.x = x;
- this.y = y;
- this.d_x = d_x;
- this.d_y = d_y;
- }
-
- damage() {
- return 0.01
- }
-
- radius() {
- return 10;
- }
-
- center() {
- return [16, 22];
- }
-}
-
-export class State {
- constructor() {
- this.player = new player.Player();
- this.enemies = [new gates.Gates()];
- this.bullets = [];
- this.count = 0;
- this.player_bullets = [];
- }
-}
-
-function dist(x1, y1, x2, y2) {
- const xdist = x1 - x2;
- const ydist = y1 - y2;
- return Math.sqrt(xdist * xdist + ydist * ydist);
-}
-
-export function overlaps(self, other) {
- const sx = self.x;
- const ox = other.x;
- const sy = self.y;
- const oy = other.y;
- const threshold = self.radius() + other.radius();
- if (Math.abs(sx - ox) >= threshold || Math.abs(sy - oy) >= threshold) {
- return false;
- }
- const d = dist(sx, sy, ox, oy);
- return d < threshold;
-}
-
-export function outside(positioned) {
- const x = positioned.x;
- const y = positioned.y;
- return x < -100
- || x > constants.x_dim + 100
- || y < -100
- || y > constants.y_dim + 100;
-}
-
-export function draw(positioned, ctx, bitmap) {
- const [cx, cy] = positioned.center();
- const x0 = Math.round(positioned.x) - cx;
- const y0 = Math.round(positioned.y) - cy;
- ctx.drawImage(bitmap, x0, y0);
-}