*/ public array $color; private float $time = 0.0; public function __construct( float $x, float $y, Vector2 $direction, EntityList $container, Room $room, float $speed = 220.0, float $size = 12.0, array $color = [0.7, 0.2, 1.0, 1.0], ) { parent::__construct($x, $y); $this->container = $container; $this->room = $room; $this->velocity = $direction->mulS($speed); $this->size = $size; $this->color = $color; $this->width = $size; $this->height = $size; } public function kind(): string { return 'projectile'; } public function update(float $dt): void { parent::update($dt); $this->time += $dt; if ( $this->pos->x < -$this->size || $this->pos->x > $this->room->width + $this->size || $this->pos->y < -$this->size || $this->pos->y > $this->room->height + $this->size ) { $this->container->remove($this); } } public function toSnapshot(): array { return [ 'eid' => $this->eid, 'd' => $this->kind(), 'x' => round($this->pos->x, 1), 'y' => round($this->pos->y, 1), 'vx' => round($this->velocity->x, 1), 'vy' => round($this->velocity->y, 1), 's' => $this->size, ]; } }