[game] Tweaks

This commit is contained in:
John Doty 2023-08-23 20:10:22 -07:00
parent 38f5f95827
commit 756a3634c0
3 changed files with 16 additions and 16 deletions

View file

@ -22,9 +22,9 @@ let actors: Actor[] = [];
// zelda screen is 16x11 tiles
// from a feeling point of view this is sufficient, apparently :D
function load_assets() {
function start_load_assets() {
// Start this load, but then...
let map_load = load_world("./overworld.ldtk").then((w) => {
load_world("./overworld.ldtk").then((w) => {
print("World loaded at", since_start());
world = w;
@ -47,17 +47,13 @@ function load_assets() {
}
}
});
Promise.all([map_load]).then(() => {
print("All are loaded.");
});
}
// TODO: Build a system whereby the signatures of the fundamental functions can be checked.
export function init() {
print("Hello world!");
load_assets();
start_load_assets();
}
interface Snapshot {
@ -66,6 +62,7 @@ interface Snapshot {
}
export function suspend(): Snapshot {
print("Suspend! ", actors.length, "actors");
return {
clock,
actors: actors.map((a) => {
@ -78,10 +75,15 @@ export function resume(snapshot: Snapshot | undefined) {
if (snapshot) {
clock = snapshot.clock || 0;
actors = snapshot.actors.map((s) => spawn_actor(s.type, s.props));
print("Resume! ", actors.length, "actors");
}
}
export function update() {
if (!level) {
return;
}
clock = (clock + 1) % 20160;
for (const actor of actors) {