oden/game/main.ts
John Doty b1b97cee75 [oden] Move graphics thread off main thread
So we can do frame pacing a little bit better maybe.
2023-06-30 16:54:16 -07:00

27 lines
686 B
TypeScript

import { cls, print, spr, use_texture } from "./graphics";
import { load_texture } from "./assets";
import { since_start, since_last_frame } from "./time";
let the_texture: number | undefined = undefined;
export function init() {
print("Hello world!");
// Start this load, but then...
load_texture("./happy-tree.png").then((n) => {
print("Tree loaded at", since_start());
the_texture = n;
});
}
export function update() {}
export function draw() {
cls(0.1, 0.2, 0.3);
if (the_texture != undefined) {
// ...it gets resolved here?
use_texture(the_texture);
spr((320 - 256) / 2, 0, 256, 240, 0, 0);
}
// print("FRAME TIME:", since_last_frame());
}