Add pi and directions

This commit is contained in:
dylan 2023-05-10 20:10:32 -07:00
parent ae3fa89a8b
commit 04f206814c
4 changed files with 18 additions and 2 deletions

View File

@ -9,8 +9,8 @@ fillEllipse,
outlineEllipse,
setPixelColor,
} from "./window.ts";
import { Font, font } from "./font.ts";
import { keyDown, keyPressed, keyReleased } from "./keyboard.ts";
import { CHAR, Font, font } from "./font.ts";
import { K, keyDown, keyPressed, keyReleased } from "./keyboard.ts";
import { addToContext, runCode } from "./runcode.ts";
import { resetRepl } from "./repl.ts";
import { COLOR } from "./colors.ts";
@ -134,6 +134,10 @@ const faux = {
getMapSheet(mapSheet)[y*64+x] = [sprSheet, spr];
},
// Input
[CHAR.UP]: K.ARROW_UP,
[CHAR.DOWN]: K.ARROW_DOWN,
[CHAR.LEFT]: K.ARROW_LEFT,
[CHAR.RIGHT]: K.ARROW_RIGHT,
btn: keyDown,
btnp: keyPressed,
btnr: keyReleased,
@ -176,6 +180,7 @@ const faux = {
sqrt: Math.sqrt,
abs: Math.abs,
rand: Math.random,
[CHAR.PI]: Math.PI,
// Other
code: (n: number) => {
return runCode(getCodeSheet(n));

View File

@ -66,6 +66,7 @@ const values = [
"undefined",
"NaN",
"Infinity",
CHAR.PI,
];
const operator = [
"&&",

View File

@ -22,6 +22,7 @@ export const CHAR = {
LEFT: "Á",
DOWN: "Â",
RIGHT: "Ã",
PI: "π"
}
export type Font = {
@ -841,5 +842,13 @@ export const font: Font = {
0, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0,
],
[CHAR.PI]: [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
1, 1, 1, 1, 1,
0, 1, 0, 1, 0,
0, 1, 0, 1, 0,
0, 0, 0, 0, 0,
],
}
};

View File

@ -67,6 +67,7 @@ export const altMap = {
"a": CHAR.LEFT,
"s": CHAR.DOWN,
"d": CHAR.RIGHT,
"p": CHAR.PI,
}
addEventListener("keydown", (evt) => {