<?phpnamespace App\Scene;use App\Core\WinZik;use App\Gui\Canvas;use JumPHP\Renderer\Renderer;use JumPHP\Scene\AbstractScene;/** * The full screen moments of WinZik (the splash, the Lock mode, A propos): drawn on a virtual screen of 640 x 480 * (the resolution A propos asked Windows for in 2001: ResolutionEcran(640, 480)), zoomed into the window. The music * goes on: WinZik ticks here too. */abstract class FullScreen extends AbstractScene{ public const W = 640; public const H = 480; protected float $time = 0.0; public function __construct(protected WinZik $wz) { } public function enter(array $params = []): void { $this->wz->attach($this->engine); $this->time = 0.0; } public function update(float $dt): void { $this->time += $dt; $this->wz->tick($dt); } /** A canvas on the 640 x 480 screen, centred and zoomed in the window. */ /** @param array{0: float, 1: float, 2: float, 3: float}|null $box the part of the 640 x 480 screen that fills the window (null: all of it) */ protected function canvas(Renderer $r, string $background = '#000000', ?array $box = null): Canvas { $r->clear($background); $c = new Canvas($r, $this->sdl()); $c->skin = $this->wz->skin; [$bx, $by, $bw, $bh] = $box ?? [0.0, 0.0, (float)self::W, (float)self::H]; $c->scale = min($r->getWidth() / $bw, $r->getHeight() / $bh); $c->at(($r->getWidth() / $c->scale - $bw) / 2 - $bx, ($r->getHeight() / $c->scale - $bh) / 2 - $by); return $c; } protected function anyInput(): bool { $input = $this->engine->input; return $input->getKeyboard()->anyPressed() || $input->getMouse()->isPressed(1) || $input->getMouse()->isPressed(3) || $input->getGamepad()->anyPressed(); } protected function showCursor(bool $on): void { // no display (tests, the playground's sandbox): no pointer to hide if (function_exists('SDL_ShowCursor') && !\JumPHP\Kernel\Platform::isHeadless()) { @\SDL_ShowCursor($on ? 1 : 0); } }}