Implement native opening scenes, battle foundation and overworld movement
Checks / web (push) Canceled after 0s

This commit is contained in:
Sébastien QUEROL committed 2026-09-23 16:09:22 +02:00
1 parent 8b80d05ca2
commit c08d250cf6
39 files changed
+10727 -1524

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
import { describe, expect, it } from "vitest";
import {
BASE_VIEWPORT,
MAX_VIEWPORT,
renderViewportForBox,
} from "../src/game/rendering/viewport";
describe("adaptive native viewport", () => {
it("keeps detached fixture canvases at the original resolution", () => {
expect(renderViewportForBox(0, 0)).toEqual({
...BASE_VIEWPORT,
pixelScale: 3,
});
expect(renderViewportForBox(Number.NaN, 500)).toEqual({
...BASE_VIEWPORT,
pixelScale: 3,
});
});
it("uses one integer scale on both axes and reveals additional world", () => {
const phone = renderViewportForBox(390, 720);
expect(phone).toEqual({ width: 195, height: 360, pixelScale: 2 });
const desktop = renderViewportForBox(960, 648);
expect(desktop).toEqual({ width: 320, height: 216, pixelScale: 3 });
expect(desktop.width).toBeGreaterThan(BASE_VIEWPORT.width);
expect(desktop.height).toBeGreaterThan(BASE_VIEWPORT.height);
expect(desktop.width * desktop.pixelScale).toBe(960);
expect(desktop.height * desktop.pixelScale).toBe(648);
});
it("rounds fractional boxes without materially changing their aspect", () => {
const css = { width: 713.5, height: 481.25 };
const viewport = renderViewportForBox(css.width, css.height);
expect(
Math.abs(viewport.width / viewport.height - css.width / css.height),
).toBeLessThan(0.005);
});
it.each([
[304, 400],
[844, 220],
[1920, 600],
[100_000, 100_000],
])(
"preserves the aspect of a %d x %d box while bounding buffers",
(width, height) => {
const viewport = renderViewportForBox(width, height);
expect(viewport.width).toBeLessThanOrEqual(MAX_VIEWPORT.width);
expect(viewport.height).toBeLessThanOrEqual(MAX_VIEWPORT.height);
expect(
Math.abs(viewport.width / viewport.height - width / height),
).toBeLessThan(0.03);
},
);
});