RU
games/satisfying-bounce / src / Scene / TitleScene.php · commit 8bdd6e4
<?phpnamespace App\Scene;use JumPHP\Kernel\Platform;use JumPHP\Renderer\TtfFont;use JumPHP\Ui\MenuScene;/** The fifteen videos, as a menu; bin/jumphp video:make films one of them directly (project.yaml video:). */final class TitleScene extends MenuScene{    protected string $title = 'SATISFYING';    protected float $titleScale = 2.5;    protected float $menuTop = 0.2;    /** @var array<string, class-string<VideoScene>> */    public const SCENES = [        'THE EXIT' => GapCircleScene::class,        'MULTIPLY' => MultiplyScene::class,        'BREAK RINGS' => ConcentricScene::class,        'MARBLE RUN' => MarbleScene::class,        'INFINITE ZOOM' => ZoomRingsScene::class,        'GROWING STAIRS' => StairsScene::class,        'TUNNEL' => TunnelScene::class,        'SPIRAL' => SpiralScene::class,        'WAVY GRID' => WaveGridScene::class,        'DOT RIPPLE' => DotRippleScene::class,        'DOMINOES' => DominoScene::class,        'CAT BOUNCE' => CatBounceScene::class,        'RAIN POND' => RainPondScene::class,        'PENDULUMS' => PendulumScene::class,        'PLINKO' => PlinkoScene::class,    ];    public function enter(array $params = []): void    {        $this->engine->device()->keepAwake();   // the screen stays on in the menu too        $this->engine->setFont(new TtfFont($this->sdl(), 'assets/fonts/Quicksand-Bold.ttf', 8, true, 0, 0.0, 0.5));        parent::enter($params);    }    protected function items(): array    {        $items = [];        foreach (self::SCENES as $label => $class) {            $items[] = [$label, null, fn () => $this->scenes()->switchTo($class, ['seed' => random_int(1, 99999)])];        }        $items[] = ['LANGUAGE', fn () => strtoupper($this->engine->lang->getLang()), null, function (int $dir): void {            $this->engine->lang->setLang($this->engine->lang->getLang() === 'fr' ? 'en' : 'fr');            $this->engine->options->set('lang', $this->engine->lang->getLang());            $this->refresh();        }];        if (Platform::isDesktop()) {            $items[] = ['QUIT', null, fn () => $this->engine->quit()];        }        return $items;    }    protected function back(): void    {    }}