animations = ['idle' => ['flags' => [], 'coords' => self::frames([[160, 32, 8, 16]])]]; $this->setAnimation('idle'); $this->startX = $this->x; $this->startY = $this->y; } /** @return Bubble[] the bubbles released this tick */ public function think(float $deltaTime): array { $bubbles = []; $this->clock += $deltaTime; while ($this->clock >= self::FRAME) { $this->clock -= self::FRAME; if (($this->frames & 0x7F) === 0 && self::SPAWN[mt_rand(0, 7)]) { $bubbles[] = new Bubble($this->sdl, $this->startX + mt_rand(0, 15), $this->startY + mt_rand(0, 15), mt_rand(0, 3) === 0); } $this->frames++; if ($this->frames % 8 === 0) { $this->step = ($this->step + 1) % 6; } } [$dx, $dy] = self::VENT[$this->step]; $this->x = $this->startX + $dx; $this->y = $this->startY + $dy; return $bubbles; } }