winzik/engine/tests/Debug/HotScene.php
David Nurdin fcb742b249 JumPHP 0.3.0: PHP 8.5; hot reload; the game on Google Play; the jumphp command for the whole system
- PHP 8.5 everywhere (desktop, relay, WebAssembly engine 8.5.12): php-sdl and php_glob patched, opcache JIT off
- hot reload of remote games (docs/hot-reload.md): assets in place, a scene entered again, or PHP restarted in
  the same engine (phpw_restart) in the scene that was playing; JumPHP\Scene\HotReloadable keeps its state
- what PHP writes goes to the page around the game (jumphp:output), phpinfo() as HTML
- bin/jumphp twa: the game as an Android app (Trusted Web Activity, Bubblewrap in Docker; docs/android.md)
- bin/jumphp cli:install: the jumphp command (tools/jumphp-cli), new projects, a question when Packagist has
  a newer JumPHP; offered by the wizard
- Testing\Game closes SDL before PHP ends (an intermittent crash at the end of the tests)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 22:17:30 +01:00

40 lines
860 B
PHP

<?php
namespace JumPHP\Tests\Debug;
use JumPHP\Renderer\Renderer;
use JumPHP\Scene\AbstractScene;
use JumPHP\Scene\HotReloadable;
/** The scene of HotReloadTest: counts its entries, keeps its score through a hot reload. */
final class HotScene extends AbstractScene implements HotReloadable
{
public int $entered = 0;
public int $score = 0;
public array $params = [];
public function enter(array $params = []): void
{
$this->entered++;
$this->score = 0;
$this->params = $params;
}
public function update(float $dt): void
{
}
public function render(Renderer $r): void
{
}
public function hotState(): array
{
return ['score' => $this->score];
}
public function hotRestore(array $state): void
{
$this->score = (int)($state['score'] ?? 0);
}
}