<?phpnamespace App\Scene;use JumPHP\Renderer\Renderer;/** * Form18 of 2001, "A propos": the screen in 640 x 480, black, the pointer hidden. Six letters are drawn at random until * each one finds its own (W, i, n, Z, i, K), red bars grow down both sides (Timer2: SetPixel), then the credits go up, * white below and fading to black at the top (Timer1: RGB(red, green, blue) from their height). A key goes back. */final class AboutScene extends FullScreen{ private const WORD = ['W', 'i', 'n', 'Z', 'i', 'K']; /** the credits of WinZiK 0.9.85 and 0.9.84 (Skins and Lyrics, found in the WinZik.exe of 2001): text, height in twips, * alignment (2 centred, 1 right) */ public const CREDITS = [ ['WinZiK V0.9.85', 7200, 2], ['Programmeur principal : ', 8300, 2], ['David NURDIN', 8900, 2], ['[email protected]', 9300, 2], ['Responsable des Skins :', 10000, 2], ['Stephane FILLION', 10600, 2], ['[email protected]', 11000, 2], ['Responsable Lyrics :', 11700, 2], ['Paul ANTOINE', 12300, 2], ['[email protected]', 12700, 2], ['Interface du site réalisée par :', 13400, 2], ['Marc GARNIER', 14000, 2], ['www.dugratis.com', 14400, 2], ['Hotline :', 15100, 2], ['Nicolas C. et David N.', 15700, 2], ['[email protected]', 16100, 2], ['Responsable du projet :', 16800, 2], ['Nicolas CHOUANIERE', 17400, 2], ['[email protected]', 17800, 2], ['Remerciements :', 18900, 2], ['Hervé NURDIN (NU²)', 19500, 2], ['Pour ses précieux conseils', 19900, 2], ['Jean-Claude NURDIN', 20600, 2], ['Pour ses graphismes', 21000, 2], ['Thomas CHOUANIERE', 21800, 2], ['Pour son soutien', 22100, 2], ['Mireille NURDIN', 22800, 2], ['pour avoir eu la patience de tester WinZiK', 23200, 2], ['Et à nos Mamans ...', 24100, 2], ["Ainsi qu'à tous les utilisateurs de WinZiK", 25100, 2], ['Tous droits réservés ©', 29400, 1], ["Ah ; ce n'est pas fini ???", 83400, 2], ['Bah y\'a rien de plus a dire', 85400, 2], ['Si ; on voulait dire :', 87400, 2], ['Vive Archettes city', 89400, 2], ]; /** @var list<string> the letters shown */ private array $letters = []; /** @var list<bool> found */ private array $found = []; private float $letterClock = 0.0; /** the credits have started (cgood) */ private float $scroll = -1.0; private float $bars = 0.0; public function enter(array $params = []): void { parent::enter($params); $this->letters = array_fill(0, 6, ' '); $this->found = array_fill(0, 6, false); $this->letterClock = -0.5; // xWait (500) $this->scroll = -1.0; $this->bars = 0.0; $this->showCursor(false); } public function exit(): void { $this->showCursor(true); } public function update(float $dt): void { parent::update($dt); if ($this->time > 0.5 && $this->anyInput()) { $this->showCursor(true); $this->scenes()->pop(); return; } if ($this->scroll < 0) { $this->letterClock += $dt; while ($this->letterClock >= 0.035) { $this->letterClock -= 0.035; $this->drawLetters(); } if (!in_array(false, $this->found, true)) { $this->scroll = 0.0; } return; } // Timer1: 200 twips every 300 ms; Timer2: the red bars, 2 pixels a step $this->scroll += $dt * (200 / 15) / 0.3; $this->bars = min(FullScreen::H, $this->bars + $dt * 240); } /** A random capital (or small letter for i, n, i) for each letter not found yet; it stays once it is the right one. */ private function drawLetters(): void { foreach (self::WORD as $i => $want) { if ($this->found[$i]) { continue; } $small = in_array($i, [1, 2, 4], true); $this->letters[$i] = chr(($small ? 97 : 65) + mt_rand(0, 26)); if ($this->letters[$i] === $want) { $this->found[$i] = true; } } } /** @return list<string> the letters on the screen (tests) */ public function letters(): array { return $this->letters; } public function scrolling(): bool { return $this->scroll >= 0; } public function render(Renderer $r): void { $c = $this->canvas($r); // the frame of the letters (Shape1) and the letters (Label2, green) $c->frame(8, 440, 625, 33, '#000000'); foreach ($this->letters as $i => $letter) { $c->text($letter, 248 + $i * 24 + 12, 442, 26, '#00ff00', 'center'); } if ($this->scroll < 0) { return; } $c->fill(0, 0, 4, $this->bars, '#ff0000'); $c->fill(635, 0, 4, $this->bars, '#ff0000'); foreach (self::CREDITS as [$text, $twips, $align]) { $y = $twips / 15 - $this->scroll; if ($y > 400 || $y < -30) { continue; } // brighter at the bottom, black at the top (red = (Top - 20) / 5, in twips) $grey = (int)max(0, min(255, ($y * 15 - 20) / 5 / 4)); $x = $align === 1 ? 620 : 320; $c->text($text, $x, $y, 18, [$grey, $grey, $grey], $align === 1 ? 'right' : 'center'); } }}