import * as player from '/static/games/stallman-shooter/player.js'; import * as gates from '/static/games/stallman-shooter/gates.js'; import * as constants from '/static/games/stallman-shooter/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); }