import { Vector2D } from './Vector2D.js'; export class GameObject { constructor(x = 0, y = 0) { this.pos = new Vector2D(x, y); this.velocity = new Vector2D(0, 0); this.width = 0; this.height = 0; } update(dt = 1 / 60) { this.pos = this.velocity.mulS(dt).addV(this.pos); } intersect(other) { return ( Math.abs(this.pos.x - other.pos.x) * 2 < this.width + other.width && Math.abs(this.pos.y - other.pos.y) * 2 < this.height + other.height ); } draw() {} remove(container) { if (!container) return; const index = container.indexOf(this); if (index !== -1) container.splice(index, 1); } }