diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-07-25 14:38:15 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-07-25 14:38:15 -0700 |
| commit | d61d78acf999527bbc24798ac62a67b7eb17874a (patch) | |
| tree | 280f7bf532b29886fb58a89bae1a29b9158d44a6 /static/games/rms/player.js | |
| parent | 9cb28a5475ca971e404e10e79e5c7d03da9ad91e (diff) | |
| download | roseh.moe-d61d78acf999527bbc24798ac62a67b7eb17874a.tar.zst | |
Consolidate JS and sprites for fewer requests
Diffstat (limited to 'static/games/rms/player.js')
| -rw-r--r-- | static/games/rms/player.js | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/static/games/rms/player.js b/static/games/rms/player.js deleted file mode 100644 index c0ff84f..0000000 --- a/static/games/rms/player.js +++ /dev/null @@ -1,88 +0,0 @@ -import * as constants from '/static/games/rms/constants.js'; - -export class Player { - constructor() { - this.x = 400; - this.y = 500; - this.x_d = 0; - this.y_d = 0; - this.down_p = false; - this.left_p = false; - this.right_p = false; - this.up_p = false; - this.fire_rate = 15; - this.shift_p = false; - } - - act(events) { - for (const event of events) { - const [kind, key] = event; - if (kind === 'keydown' && key === 'ArrowDown') { - this.down_p = true; - this.y_d = -1; - } else if (kind === 'keyup' && key === 'ArrowDown') { - this.down_p = false; - } else if (kind === 'keydown' && key === 'ArrowUp') { - this.up_p = true; - this.y_d = 1; - } else if (kind === 'keyup' && key === 'ArrowUp') { - this.up_p = false; - } else if (kind === 'keydown' && key === 'ArrowLeft') { - this.left_p = true; - this.x_d = -1; - } else if (kind === 'keyup' && key === 'ArrowLeft') { - this.left_p = false; - } else if (kind === 'keydown' && key === 'ArrowRight') { - this.right_p = true; - this.x_d = 1; - } else if (kind === 'keyup' && key === 'ArrowRight') { - this.right_p = false; - } else if (kind === 'keydown' && key === 'Shift') { - this.shift_p = true; - } else if (kind === 'keyup' && key === 'Shift') { - this.shift_p = false; - } - } - if (this.left_p) { - if (!this.right_p) { - this.x_d = -1; - } - } else if (this.right_p) { - this.x_d = 1; - } else { - this.x_d = 0; - } - if (this.up_p) { - if (!this.down_p) { - this.y_d = -1; - } - } else if (this.down_p) { - this.y_d = 1; - } else { - this.y_d = 0; - } - /* Don't go off the side */ - if (this.x_d < 0 && this.x <= 0 || this.x >= constants.x_dim && this.x_d > 0) { - this.x_d = 0; - } - if (this.y <= 0 && this.y_d < 0 || this.y >= constants.y_dim && this.y_d > 0) { - this.y_d = 0; - } - - if (this.shift_p) { - this.x += this.x_d; - this.y += this.y_d; - } else { - this.x += this.x_d * 3; - this.y += this.y_d * 3; - } - } - - radius() { - return 3; - } - - center() { - return [33, 21]; - } -} |
