<?phpnamespace Tests;use App\Engine\Art;use App\Engine\SoftRenderer;use App\Game\Campaign;use App\Game\Info;final class RendererTest extends WorldTestCase{ public function testEveryLevelBuildsAndEveryCellIsInItsSector(): void { foreach ([...Campaign::LEVELS, 'test'] as $id) { $w = $this->load($id); $map = $w->level->data['map']; foreach ($map as $r => $row) { for ($c = 0; $c < strlen($row); $c++) { $def = $w->level->data['legend'][$row[$c]] ?? null; if ($def === null || !empty($def['solid']) || isset($def['diag'])) { continue; } $s = $w->level->sectorAt(...$this->cell($c, $r)); self::assertSame($row[$c], $s->char, "$id: cell $c,$r"); } } self::assertSame(1, count(array_filter($w->level->things, fn ($t) => $t['type'] === 'player')), "$id: one start"); foreach ($w->level->things as $t) { Info::type($t['type']); } } } public function testTheViewIsDrawnEverywhere(): void { $this->load('m1'); $art = Art::get(dirname(__DIR__) . '/assets/data/art.pak'); $r = new SoftRenderer($art, 320, 168); $mo = $this->world->player->mo; foreach ([0, 90, 180, 270] as $deg) { $r->fb = str_repeat("\xFF", 320 * 168); $r->render($this->world->level, $mo->x, $mo->y, $mo->z + 41, deg2rad($deg), $mo); self::assertGreaterThan(0, $r->stats['segs']); // no pixel left unpainted (no hole in the walls / floors) self::assertLessThan(320 * 168 * 0.002, substr_count($r->fb, "\xFF"), "holes at $deg degrees"); } }}