[oden] Move scaling entirely into JavaScript

Now the game controls its own resolution. We might want to further
copy Love2D and generate resize events, I don't know.
This commit is contained in:
John Doty 2023-09-02 09:58:58 -07:00
parent 994be3e493
commit 1cb30034f8
9 changed files with 176 additions and 58 deletions

View file

@ -1,4 +1,4 @@
import { cls } from "./graphics";
import { cls, get_dimensions, scale } from "./graphics";
import { since_start } from "./time";
import { new_v2 } from "./vector";
import { load_world, World, Level, draw_level } from "./level";
@ -102,6 +102,13 @@ export function update() {
export function draw() {
cls(0.1, 0.2, 0.3);
const dimensions = get_dimensions();
const s = Math.max(
1,
Math.floor(Math.min(dimensions[0] / 320, dimensions[1] / 240))
);
scale(s);
if (level != undefined) {
draw_level(level, 0, 0);
}