oden/game/main.ts

26 lines
639 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);
}
}