summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-07 23:48:04 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-07 23:48:04 -0700
commit634b2c1b69b9cc107546b12e710fc2daec53fcec (patch)
tree27b3396a227ace81fea583c62fbb36458cb1eebe
parentea6c1eef48ba8d39defdd8cd78adc45ae660caf9 (diff)
downloadthe-abstraction-engine-634b2c1b69b9cc107546b12e710fc2daec53fcec.tar.gz
the-abstraction-engine-634b2c1b69b9cc107546b12e710fc2daec53fcec.zip
minor bug fixes
-rw-r--r--public/assets/portal.pngbin1320 -> 8493 bytes
-rw-r--r--src/engine/config/sprites.ts4
-rw-r--r--src/engine/entities/LambdaFactory.ts13
-rw-r--r--src/engine/levels/Tutorial.ts3
-rw-r--r--src/interpreter/PeggyParser.js4
-rw-r--r--src/interpreter/parser.ts8
6 files changed, 17 insertions, 15 deletions
diff --git a/public/assets/portal.png b/public/assets/portal.png
index 240a9a1..9197be3 100644
--- a/public/assets/portal.png
+++ b/public/assets/portal.png
Binary files differ
diff --git a/src/engine/config/sprites.ts b/src/engine/config/sprites.ts
index 0a4f9b5..3614488 100644
--- a/src/engine/config/sprites.ts
+++ b/src/engine/config/sprites.ts
@@ -110,10 +110,10 @@ const bubbleSpriteSpec = {
SPRITE_SPECS.set(Sprites.BUBBLE, bubbleSpriteSpec);
const portalSpriteSpec = {
- msPerFrame: 200,
+ msPerFrame: 150,
width: 64,
height: 64,
- frames: 3,
+ frames: 9,
sheet: "/assets/portal.png",
};
SPRITE_SPECS.set(Sprites.PORTAL, portalSpriteSpec);
diff --git a/src/engine/entities/LambdaFactory.ts b/src/engine/entities/LambdaFactory.ts
index 9ad1398..770c096 100644
--- a/src/engine/entities/LambdaFactory.ts
+++ b/src/engine/entities/LambdaFactory.ts
@@ -143,12 +143,19 @@ export class LambdaFactory extends Entity {
}
private spawnNewLambda(direction: Direction) {
+ try {
+ parse(this.code);
+ } catch (e: any) {
+ SOUNDS.get(Failure.name)!.play();
+ return;
+ }
+
const spawner = this.getComponent<GridSpawn>(ComponentNames.GridSpawn);
spawner.spawnEntity(direction);
- const text = this.getComponent<Text>(ComponentNames.Text);
- text.text = spawner.spawnsLeft.toString();
- this.addComponent(text);
+ const textComponent = this.getComponent<Text>(ComponentNames.Text);
+ textComponent.text = spawner.spawnsLeft.toString();
+ this.addComponent(textComponent);
SOUNDS.get(LambdaTransformSound.name)!.play();
}
diff --git a/src/engine/levels/Tutorial.ts b/src/engine/levels/Tutorial.ts
index 165b10f..694c8ff 100644
--- a/src/engine/levels/Tutorial.ts
+++ b/src/engine/levels/Tutorial.ts
@@ -22,8 +22,7 @@ export class Tutorial extends Level {
new Wall({ x: 11, y: 10 }),
new Curry({ x: 10, y: 10 }),
new LockedDoor({ x: 9, y: 10 }),
- new LambdaFactory({ x: 6, y: 3 }, "(λ (x) . x)", 3),
-
+ new LambdaFactory({ x: 6, y: 3 }, "// TODO: Remove line\n(λ (x) . x)", 3),
new FunctionApplication({ x: 6, y: 6 }, "(_INPUT key)"),
];
diff --git a/src/interpreter/PeggyParser.js b/src/interpreter/PeggyParser.js
index 632f1b7..5671d91 100644
--- a/src/interpreter/PeggyParser.js
+++ b/src/interpreter/PeggyParser.js
@@ -201,7 +201,7 @@ export default (function () {
);
};
- function peg$parse(input, options, allowUnderscores = false) {
+ function peg$parse(input, options) {
options = options !== undefined ? options : {};
var peg$FAILED = {};
@@ -215,7 +215,7 @@ export default (function () {
var peg$c2 = ".";
var peg$c3 = "\r\n";
- var peg$r0 = allowUnderscores ? /^[a-zA-Z0-9]_/ : /^[a-zA-Z0-9]/;
+ var peg$r0 = /^[a-zA-Z0-9]/;
var peg$r1 = /^[\\\u03BB]/;
var peg$r2 = /^[\t-\n ]/;
diff --git a/src/interpreter/parser.ts b/src/interpreter/parser.ts
index d288815..5e3be0f 100644
--- a/src/interpreter/parser.ts
+++ b/src/interpreter/parser.ts
@@ -30,10 +30,6 @@ export const isVariable = (term: LambdaTerm): term is Variable => {
return typeof term === "string";
};
-export const parse = (
- term: string,
- allowUnderscores = false,
- library = false,
-) => {
- return peggyParser.parse(term, { peg$library: library }, allowUnderscores);
+export const parse = (term: string, library = false) => {
+ return peggyParser.parse(term, { peg$library: library });
};