6 Commits
Author SHA1 Message Date
Dylan Pizzo 86d605b130 Update the readme 2025-02-19 20:04:40 -08:00
dylan f652e8d20f Reorganize 2023-05-18 19:45:49 -07:00
dylan 9b48560cce Allow top level await 2023-05-16 23:45:29 -07:00
dylan 9cb77c7d59 Update README again 2023-05-14 23:41:46 -07:00
dylan a7efee86e5 Update README 2023-05-14 23:39:22 -07:00
dylan a9f153e379 Automate more of build process 2023-05-14 23:20:36 -07:00
24 changed files with 107 additions and 96 deletions
+17 -5
View File
@@ -1,13 +1,25 @@
# fantasy-console
# Faux
To run,
This is a custom fantasy-console (like Pico 8) written in Deno/Typescript.
Go to the [Releases](https://git.playbox.link/dylan/fantasy-console/releases) page to find downloadable executables.
NOTE: If you are running Faux on Linux, you will need to have `xsel` installed.
## Developing
Faux is written in [TypeScript](https://www.typescriptlang.org/) to be run or compiled by [Deno](https://deno.com/runtime).
If you want to build from source, you should have Deno installed, clone this repo, and then...
To run:
```
deno task run
```
To compile
To compile:
```
deno task build
deno task build_all
```
You may need to install `xsel` on Linux machines to use this.
NOTE: Development is happening solely on Linux, so some build commands may fail if you are not on Linux or do not have some build dependencies installed.
View File
View File
View File
+2 -2
View File
@@ -5,8 +5,8 @@
"tasks": {
"run": "deno run -A --unstable index.ts",
"build": "deno compile --output build/faux -A --unstable index.ts",
"build_linux": "deno compile --output build/faux_linux --target x86_64-unknown-linux-gnu -A --unstable index.ts",
"build_windows": "deno compile --output build/faux_windows --target x86_64-pc-windows-msvc -A --unstable index.ts",
"build_linux": "mkdir -p ./build/zips ; mkdir -p ./build/linux ; cp ./manual.md ./build/linux/README.md ; deno compile --output build/linux/faux --target x86_64-unknown-linux-gnu -A --unstable index.ts ; cd ./build/linux ; zip -r ../zips/faux_linux.zip . ; cd ../..",
"build_windows": "mkdir -p ./build/zips ; mkdir -p ./build/windows ; cp ./manual.md ./build/windows/README.md ; deno compile --output build/windows/faux --target x86_64-pc-windows-msvc -A --unstable index.ts ; cd ./build/windows ; zip -r ../zips/faux_windows.zip . ; cd ../..",
"build_all": "deno task build_linux & deno task build_windows"
}
}
View File
+9 -9
View File
@@ -1,13 +1,13 @@
import { clearScreen, fillRect } from "./window.ts";
import { CHAR, font } from "./font.ts";
import { drawText, measureText } from "./builtins.ts";
import { COLOR } from "./colors.ts";
import { getCodeSheet, setSheet } from "./sheet.ts";
import { K, ctrlKeyDown, getKeyboardString, keyPressed, shiftKeyDown } from "./keyboard.ts";
import { clipboard, tokenize } from "./deps.ts";
import { getBuiltins } from "./runcode.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { CHAR, font } from "../data/font.ts";
import { drawText, measureText } from "../runtime/builtins.ts";
import { COLOR } from "../data/colors.ts";
import { getCodeSheet, setSheet } from "../io/sheet.ts";
import { K, ctrlKeyDown, getKeyboardString, keyPressed, shiftKeyDown } from "../io/keyboard.ts";
import { clipboard, tokenize } from "../deps.ts";
import { getBuiltins } from "../runtime/runcode.ts";
import { page } from "./viewsheets.ts";
import { mouseDown, mouseHeld, mousePos } from "./mouse.ts";
import { mouseDown, mouseHeld, mousePos } from "../io/mouse.ts";
const historyDebounceFrames = 20;
+7 -7
View File
@@ -1,13 +1,13 @@
import { clearScreen, fillRect } from "./window.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { codetab } from "./codetab.ts";
import { spritetab } from "./spritetab.ts";
import { viewsheets, page } from "./viewsheets.ts";
import { COLOR } from "./colors.ts";
import { mouseClick, mousePos } from "./mouse.ts";
import { drawIcon } from "./builtins.ts";
import { inRect } from "./util.ts";
import { sheetsIcon, trashIcon } from "./icons.ts";
import { SheetType, setSheet } from "./sheet.ts";
import { COLOR } from "../data/colors.ts";
import { mouseClick, mousePos } from "../io/mouse.ts";
import { drawIcon } from "../runtime/builtins.ts";
import { inRect } from "../util/util.ts";
import { sheetsIcon, trashIcon } from "../data/icons.ts";
import { SheetType, setSheet } from "../io/sheet.ts";
import { nonetab } from "./nonetab.ts";
import { maptab } from "./maptab.ts";
+7 -9
View File
@@ -1,13 +1,11 @@
import { clearScreen, fillRect } from "./window.ts";
import { drawSprite, drawText } from "./builtins.ts";
import { COLOR } from "./colors.ts";
import { getMapSheet, getSheet, setSheet } from "./sheet.ts";
import { M, mouseClick, mouseDown, mouseHeld, mousePos } from "./mouse.ts";
import { drawTransparentRect, drawVoidRect, inRect, reGrid } from "./util.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { drawSprite, drawText, useSpritesheet } from "../runtime/builtins.ts";
import { COLOR } from "../data/colors.ts";
import { getMapSheet, getSheet, setSheet } from "../io/sheet.ts";
import { M, mouseClick, mouseDown, mouseHeld, mousePos } from "../io/mouse.ts";
import { drawTransparentRect, drawVoidRect, inRect, reGrid } from "../util/util.ts";
import { page } from "./viewsheets.ts";
import { useSpritesheet } from "./builtins.ts";
import { keyPressed } from "./keyboard.ts";
import { K } from "./keyboard.ts";
import { keyPressed, K } from "../io/keyboard.ts";
const state = {
selectedSpriteSheet: 0,
+7 -8
View File
@@ -1,12 +1,11 @@
import { clearScreen, fillRect } from "./window.ts";
import { drawIcon, drawText } from "./builtins.ts";
import { COLOR } from "./colors.ts";
import { getSheet, setSheet } from "./sheet.ts";
import { mouseClick, mousePos } from "./mouse.ts";
import { reGridWithGap } from "./util.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { drawIcon, drawText, useSpritesheet } from "../runtime/builtins.ts";
import { COLOR } from "../data/colors.ts";
import { getSheet, setSheet } from "../io/sheet.ts";
import { mouseClick, mousePos } from "../io/mouse.ts";
import { reGridWithGap } from "../util/util.ts";
import { page } from "./viewsheets.ts";
import { useSpritesheet } from "./builtins.ts";
import { codeIcon, mapIcon, spriteIcon } from "./icons.ts";
import { codeIcon, mapIcon, spriteIcon } from "../data/icons.ts";
const gridX = 8;
const gridY = 40;
+6 -7
View File
@@ -1,11 +1,10 @@
import { clearScreen, fillRect } from "./window.ts";
import { drawSprite, drawText } from "./builtins.ts";
import { COLOR } from "./colors.ts";
import { getSpriteSheet, setSheet } from "./sheet.ts";
import { mouseClick, mouseHeld, mousePos } from "./mouse.ts";
import { drawTransparentRect, inRect, outlineRect, reGrid } from "./util.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { drawSprite, drawText, useSpritesheet } from "../runtime/builtins.ts";
import { COLOR } from "../data/colors.ts";
import { getSpriteSheet, setSheet } from "../io/sheet.ts";
import { mouseClick, mouseHeld, mousePos } from "../io/mouse.ts";
import { drawTransparentRect, inRect, outlineRect, reGrid } from "../util/util.ts";
import { page } from "./viewsheets.ts";
import { useSpritesheet } from "./builtins.ts";
const state = {
selectedSprite: 0,
+9 -9
View File
@@ -1,12 +1,12 @@
import { clearScreen, fillRect } from "./window.ts";
import { drawIcon, drawText } from "./builtins.ts";
import { COLOR } from "./colors.ts";
import { getSheet } from "./sheet.ts";
import { mouseClick, mousePos } from "./mouse.ts";
import { getCart } from "./cart.ts";
import { font } from "./font.ts";
import { codeIcon, spriteIcon, mapIcon } from "./icons.ts";
import { reGridWithGap } from "./util.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { drawIcon, drawText } from "../runtime/builtins.ts";
import { COLOR } from "../data/colors.ts";
import { getSheet } from "../io/sheet.ts";
import { mouseClick, mousePos } from "../io/mouse.ts";
import { getCart } from "../io/cart.ts";
import { font } from "../data/font.ts";
import { codeIcon, spriteIcon, mapIcon } from "../data/icons.ts";
import { reGridWithGap } from "../util/util.ts";
const fontHeight = font.height;
+13 -13
View File
@@ -2,24 +2,24 @@ import {
mainloop,
frame,
clearScreen,
} from "./window.ts";
import { runCode } from "./runcode.ts";
import { getCodeSheet } 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";
import { refreshMouse } from "./mouse.ts";
import { camera } from "./builtins.ts";
} from "./io/window.ts";
import { runCode } from "./runtime/runcode.ts";
import { getCodeSheet } from "./io/sheet.ts";
import { refreshKeyboard, keyPressed, K } from "./io/keyboard.ts";
import { repl, resetRepl } from "./repl/repl.ts";
import { addToContext } from "./runtime/runcode.ts";
import { editmode } from "./editor/editmode.ts";
import { refreshMouse } from "./io/mouse.ts";
import { camera } from "./runtime/builtins.ts";
// deno-lint-ignore no-explicit-any
let game: any = null;
let mode: "play" | "edit" | "repl" = "repl";
addToContext("play", () => {
addToContext("play", async () => {
game = await runCode(getCodeSheet(0));
mode = "play";
game = runCode(getCodeSheet(0));
game.init();
});
@@ -43,8 +43,8 @@ await mainloop(async (_t) => {
} else {
if (mode === "play") {
if (game) {
game.update();
game.draw();
await game.update();
await game.draw();
}
frame();
} else if (mode === "repl") {
+2 -2
View File
@@ -1,5 +1,5 @@
import { path } from "./deps.ts";
import initialCart from "./initialCart.json" assert { type: "json" };
import { path } from "../deps.ts";
import initialCart from "../data/initialCart.json" assert { type: "json" };
import { Sheet } from "./sheet.ts";
const extension = ".faux";
+1 -1
View File
@@ -1,4 +1,4 @@
import { font, CHAR } from "./font.ts";
import { font, CHAR } from "../data/font.ts";
const keyboard = new Map<number, {first: boolean, repeat: boolean, held: boolean}>();
View File
+1 -1
View File
@@ -1,5 +1,5 @@
import { getCart } from "./cart.ts";
import { LinearGrid } from "./util.ts";
import { LinearGrid } from "../util/util.ts";
// import { runCode, addToContext } from "./runcode.ts";
// "code" | "spritesheet" | "map" | "sfx" | "patterns" | "fonts"
+3 -3
View File
@@ -2,9 +2,9 @@ import {
createWindow,
getProcAddress,
gl,
} from "./deps.ts";
export {mainloop} from "./deps.ts";
import { COLOR, palette } from "./colors.ts";
} from "../deps.ts";
export {mainloop} from "../deps.ts";
import { COLOR, palette } from "../data/colors.ts";
export const gameWindow = createWindow({
title: "Faux",
+6 -6
View File
@@ -1,9 +1,9 @@
import { drawText} from "./builtins.ts";
import { getKeysPressed, shiftKeyDown, shiftMap, K } from "./keyboard.ts";
import { font } from "./font.ts";
import { addToContext, evalCode } from "./runcode.ts";
import { clearScreen, fillRect } from "./window.ts";
import { COLOR } from "./colors.ts";
import { drawText} from "../runtime/builtins.ts";
import { getKeysPressed, shiftKeyDown, shiftMap, K } from "../io/keyboard.ts";
import { font } from "../data/font.ts";
import { addToContext, evalCode } from "../runtime/runcode.ts";
import { clearScreen, fillRect } from "../io/window.ts";
import { COLOR } from "../data/colors.ts";
const lineHeight = 6;
+8 -8
View File
@@ -8,15 +8,15 @@ outlineCircle,
fillEllipse,
outlineEllipse,
setPixelColor,
} from "./window.ts";
import { CHAR, Font, font } from "./font.ts";
import { K, keyDown, keyPressed, keyReleased } from "./keyboard.ts";
} from "../io/window.ts";
import { CHAR, Font, font } from "../data/font.ts";
import { K, keyDown, keyPressed, keyReleased } from "../io/keyboard.ts";
import { addToContext, runCode } from "./runcode.ts";
import { resetRepl } from "./repl.ts";
import { COLOR } from "./colors.ts";
import { getSheet, getCodeSheet, getMapSheet } from "./sheet.ts";
import { saveCart, loadCart } from "./cart.ts";
import { outlineRect } from "./util.ts";
import { resetRepl } from "../repl/repl.ts";
import { COLOR } from "../data/colors.ts";
import { getSheet, getCodeSheet, getMapSheet } from "../io/sheet.ts";
import { saveCart, loadCart } from "../io/cart.ts";
import { outlineRect } from "../util/util.ts";
let spritesheet: number | null = null;
+7 -4
View File
@@ -13,6 +13,9 @@ export const getBuiltins = () => {
return builtins;
}
// deno-lint-ignore no-explicit-any
const AsyncFunction = (async function () {}).constructor as any;
addToContext("eval", eval);
const context = new Proxy(G, {
@@ -31,18 +34,18 @@ const context = new Proxy(G, {
},
});
export const runCode = (code: string) => {
export const runCode = async (code: string) => {
try {
new Function(code);
new AsyncFunction(code);
} catch (err) {
throw err;
}
const fn = new Function("context", `
const fn = new AsyncFunction("context", `
with (context) {
${code}
}
`);
return fn(context);
return await fn(context);
}
export const evalCode = (code: string) => {
+2 -2
View File
@@ -1,5 +1,5 @@
import { COLOR } from "./colors.ts";
import { fillRect, setPixelColor } from "./window.ts";
import { COLOR } from "../data/colors.ts";
import { fillRect, setPixelColor } from "../io/window.ts";
export const inRect = (x: number, y: number, rectX: number, rectY: number, rectW: number, rectH: number) => {
return (