session->bigDiamonds) >= 7; $this->pages = array_merge([self::STORY], $won ? self::GOOD_ENDING : self::BAD_ENDING, [self::STAFF]); if ($won) { $this->session->addScore(1000000); } $this->session->saveHiScore(); $this->page = 0; $this->time = 0.0; $this->sound()->playMusic('theme'); } public function update(float $dt): void { $this->time += $dt; $actions = $this->actions(); if ($this->time >= self::PAGE_TIME || ($this->time > 0.5 && ($actions->isPressed('fire') || $actions->isPressed('confirm')))) { $this->time = 0.0; if (++$this->page >= count($this->pages)) { $this->scenes()->switchTo(TitleScene::class); } } if ($actions->isPressed('back')) { $this->scenes()->switchTo(TitleScene::class); } } public function render(Renderer $r): void { $r->clear([0, 0, 0]); $this->scoreBoard->render($r, $this->font()); $lines = $this->pages[min($this->page, count($this->pages) - 1)]; $y = 96 - count($lines) * 6; foreach ($lines as $i => $line) { $colour = $this->page === count($this->pages) - 1 && $i === 0 ? ArcadeFont::YELLOW : ArcadeFont::WHITE; $this->font()->draw($r, $line, $this->width() / 2, $y + $i * 12, 1, $colour, 'center'); } } }