Fix sample cart, and get ready for edit mode
This commit is contained in:
17
index.ts
17
index.ts
@ -7,6 +7,7 @@ import { codeSheet } from "./sheet.ts";
|
||||
import { refreshKeyboard, keyPressed, K } from "./keyboard.ts";
|
||||
import { repl, resetRepl } from "./repl.ts";
|
||||
import { addToContext } from "./runcode.ts";
|
||||
import { editmode } from "./editmode.ts";
|
||||
|
||||
const game = codeSheet(0);
|
||||
|
||||
@ -21,18 +22,19 @@ clearScreen();
|
||||
await mainloop((_t) => {
|
||||
// TODO: use t
|
||||
if (keyPressed(K.ESCAPE)) {
|
||||
console.log('pressed escape');
|
||||
const modeTo = ({
|
||||
play: "repl",
|
||||
edit: "repl",
|
||||
repl: "edit",
|
||||
} as const)[mode];
|
||||
console.log(`pressed escape (${mode} -> ${modeTo})`);
|
||||
if (mode === "play") {
|
||||
resetRepl();
|
||||
}
|
||||
if (mode === "edit") {
|
||||
clearScreen();
|
||||
}
|
||||
mode = ({
|
||||
play: "repl",
|
||||
edit: "repl",
|
||||
repl: "edit",
|
||||
} as const)[mode];
|
||||
mode = modeTo;
|
||||
} else {
|
||||
if (mode === "play") {
|
||||
game.update();
|
||||
@ -43,7 +45,8 @@ await mainloop((_t) => {
|
||||
repl.draw();
|
||||
frame();
|
||||
} else if (mode === "edit") {
|
||||
clearScreen();
|
||||
editmode.update();
|
||||
editmode.draw();
|
||||
frame();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user