eid = ++self::$nextId; $this->pos = new Vector2($x, $y); $this->velocity = Vector2::zero(); $this->width = 0.0; $this->height = 0.0; } public function update(float $dt): void { $this->move($dt); } /** Integrate position from velocity; used directly by subclasses that override update(). */ public function move(float $dt): void { $this->pos = new Vector2( $this->pos->x + $this->velocity->x * $dt, $this->pos->y + $this->velocity->y * $dt, ); } public function intersects(GameObject $other): bool { return abs($this->pos->x - $other->pos->x) * 2.0 < $this->width + $other->width && abs($this->pos->y - $other->pos->y) * 2.0 < $this->height + $other->height; } public function removeFrom(EntityList $container): void { $container->remove($this); } abstract public function kind(): string; }