[oden][game] Multiple screens, logging, pre/post, bluescreen

Better blue screens and also logging and whatnot
This commit is contained in:
John Doty 2023-09-11 20:41:11 -07:00
parent 95d626c15f
commit 93d4e3eb91
8 changed files with 1201 additions and 244 deletions

View file

@ -1,17 +1,35 @@
import { color, print } from "./graphics";
const lines: string[] = [];
interface LogEntry {
frame_age: number;
line: string;
}
export function log(...args: unknown[]) {
// const line = args.join(" ");
lines.push(args.join(" "));
const lines: Map<string, LogEntry> = new Map();
export function log(key: string, ...args: unknown[]) {
const entry = {
frame_age: 60,
line: key + " " + args.join(" "),
};
lines.set(key, entry);
}
export function draw_log() {
color(1, 1, 1, 1);
let line_y = 3;
for (const line of lines) {
print(3, line_y, line);
line_y += 8;
const keys = [...lines.keys()].sort();
for (const key of keys) {
const entry = lines.get(key);
if (entry) {
// Life is too short for me to convince typescript.
print(3, line_y, entry.line);
line_y += 8;
entry.frame_age -= 1;
if (entry.frame_age <= 0) {
lines.delete(key);
}
}
}
}