- 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]>
40 lines
860 B
PHP
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);
|
|
}
|
|
}
|