*/ public array $color; public Player $owner; public function __construct( float $x, float $y, Vector2 $direction, EntityList $container, Room $room, Player $owner, float $speed = 800.0, float $size = 8.0, int $damage = 1, ) { parent::__construct($x, $y); $this->container = $container; $this->room = $room; $this->owner = $owner; $this->velocity = $direction->mulS($speed); $this->size = $size; $this->damage = $damage; $this->color = [1.0, 0.2, 0.2, 1.0]; $this->width = $size; $this->height = $size; } public function kind(): string { return 'bullet'; } public function update(float $dt): void { parent::update($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, ]; } }