[oden][game] Multiple screens, logging, pre/post, bluescreen
Better blue screens and also logging and whatnot
This commit is contained in:
parent
95d626c15f
commit
93d4e3eb91
8 changed files with 1201 additions and 244 deletions
26
game/main.ts
26
game/main.ts
|
|
@ -1,7 +1,7 @@
|
|||
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";
|
||||
import { load_world, World, draw_level } from "./level";
|
||||
import {
|
||||
Actor,
|
||||
ActorProps,
|
||||
|
|
@ -16,7 +16,6 @@ import { log, draw_log } from "./log";
|
|||
let clock = 0;
|
||||
|
||||
let world: World | undefined = undefined;
|
||||
let level: Level | undefined = undefined;
|
||||
let actors: Actor[] = [];
|
||||
|
||||
// Note zelda overworld is 16x8 screens
|
||||
|
|
@ -26,14 +25,11 @@ let actors: Actor[] = [];
|
|||
function start_load_assets() {
|
||||
// Start this load, but then...
|
||||
load_world("./overworld.ldtk").then((w) => {
|
||||
log("World loaded at", since_start());
|
||||
log("world loaded at", since_start());
|
||||
world = w;
|
||||
|
||||
// Assume we start at 0,0
|
||||
level = world.levels.find((l) => l.world_x == 0 && l.world_y == 0);
|
||||
if (!level) {
|
||||
throw new Error("UNABLE TO FIND LEVEL AT 0,0: CANNOT START");
|
||||
}
|
||||
const level = world.current_level;
|
||||
|
||||
// TODO: SPAWN ACTORS BASED ON LEVEL.
|
||||
actors.length = 0;
|
||||
|
|
@ -63,7 +59,7 @@ interface Snapshot {
|
|||
}
|
||||
|
||||
export function suspend(): Snapshot {
|
||||
log("Suspend! ", actors.length, "actors");
|
||||
log("suspend_status", "Suspend ", actors.length, "actors");
|
||||
return {
|
||||
clock,
|
||||
actors: actors.map((a) => {
|
||||
|
|
@ -76,23 +72,19 @@ export function resume(snapshot: Snapshot | undefined) {
|
|||
if (snapshot) {
|
||||
clock = snapshot.clock || 0;
|
||||
actors = snapshot.actors.map((s) => spawn_actor(s.type, s.props));
|
||||
log("Resume! ", actors.length, "actors");
|
||||
log("resume_status", "Resume ", actors.length, "actors");
|
||||
}
|
||||
}
|
||||
|
||||
export function update() {
|
||||
if (!level) {
|
||||
if (!world) {
|
||||
return;
|
||||
}
|
||||
|
||||
clock = (clock + 1) % 20160;
|
||||
|
||||
for (const actor of actors) {
|
||||
actor.update();
|
||||
}
|
||||
|
||||
for (const actor of actors) {
|
||||
actor.update_physics(level);
|
||||
actor.update(world);
|
||||
}
|
||||
|
||||
// TODO: Bonks
|
||||
|
|
@ -109,8 +101,8 @@ export function draw() {
|
|||
);
|
||||
scale(s);
|
||||
|
||||
if (level != undefined) {
|
||||
draw_level(level, 0, 0);
|
||||
if (world != undefined) {
|
||||
draw_level(world.current_level, 0, 0);
|
||||
}
|
||||
|
||||
for (const actor of actors) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue