Make changes playable
This commit is contained in:
17
index.ts
17
index.ts
@ -9,13 +9,16 @@ import { repl, resetRepl } from "./repl.ts";
|
||||
import { addToContext } from "./runcode.ts";
|
||||
import { editmode } from "./editmode.ts";
|
||||
|
||||
const game = codeSheet(0);
|
||||
|
||||
game.init();
|
||||
// deno-lint-ignore no-explicit-any
|
||||
let game: any = null;
|
||||
|
||||
let mode: "play" | "edit" | "repl" = "repl";
|
||||
|
||||
addToContext("play", () => {mode = "play"});
|
||||
addToContext("play", () => {
|
||||
mode = "play";
|
||||
game = codeSheet(0);
|
||||
game.init();
|
||||
});
|
||||
|
||||
clearScreen();
|
||||
|
||||
@ -37,8 +40,10 @@ await mainloop((_t) => {
|
||||
mode = modeTo;
|
||||
} else {
|
||||
if (mode === "play") {
|
||||
game.update();
|
||||
game.draw();
|
||||
if (game) {
|
||||
game.update();
|
||||
game.draw();
|
||||
}
|
||||
frame();
|
||||
} else if (mode === "repl") {
|
||||
repl.update();
|
||||
|
Reference in New Issue
Block a user