diff --git a/editmode.ts b/editmode.ts index 435d0bc..490db61 100644 --- a/editmode.ts +++ b/editmode.ts @@ -1,10 +1,9 @@ import { clearScreen, fillRect } from "./window.ts"; -import { font, fontWidth, fontHeight } from "./font.ts"; +import { fontWidth, fontHeight } from "./font.ts"; import { drawText } from "./builtins.ts"; import { COLOR } from "./colors.ts"; -import { getCart } from "./cart.ts"; import {getSheet, setSheet} from "./sheet.ts"; -import { K, getKeyboardString, getKeysPressed, keyDown, keyPressed, shiftKeyDown } from "./keyboard.ts"; +import { K, getKeyboardString, keyPressed, shiftKeyDown } from "./keyboard.ts"; // deno-lint-ignore prefer-const let tab: "code" | "sprite" | "map" | "sfx" | "music" = "code"; @@ -150,7 +149,7 @@ const drawCodeField = (code: string, x: number, y: number, w: number, h: number) const update = () => { if (tab === "code") { - const {code, anchor, focus, focusX, focusY} = codeTabState; + const { focus, focusX, focusY} = codeTabState; const keyboardString = getKeyboardString(); if (keyboardString) { codeTabState.insertText(keyboardString); diff --git a/index.ts b/index.ts index e8e3620..071267c 100644 --- a/index.ts +++ b/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();