summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine/Game.ts6
-rw-r--r--src/engine/TheAbstractionEngine.ts4
-rw-r--r--src/engine/components/BoundingBox.ts4
-rw-r--r--src/engine/components/GridSpawn.ts2
-rw-r--r--src/engine/components/Highlight.ts2
-rw-r--r--src/engine/components/Sprite.ts4
-rw-r--r--src/engine/components/Text.ts2
-rw-r--r--src/engine/config/assets.ts25
-rw-r--r--src/engine/config/constants.ts2
-rw-r--r--src/engine/config/sprites.ts2
-rw-r--r--src/engine/entities/Curry.ts10
-rw-r--r--src/engine/entities/FunctionApplication.ts18
-rw-r--r--src/engine/entities/FunctionBox.ts14
-rw-r--r--src/engine/entities/Grass.ts4
-rw-r--r--src/engine/entities/Key.ts10
-rw-r--r--src/engine/entities/LambdaFactory.ts22
-rw-r--r--src/engine/entities/LockedDoor.ts10
-rw-r--r--src/engine/entities/Particles.ts16
-rw-r--r--src/engine/entities/Player.ts10
-rw-r--r--src/engine/entities/Portal.ts8
-rw-r--r--src/engine/entities/Wall.ts10
-rw-r--r--src/engine/systems/Collision.ts6
-rw-r--r--src/engine/systems/FacingDirection.ts8
-rw-r--r--src/engine/systems/Grid.ts40
-rw-r--r--src/engine/systems/Input.ts20
-rw-r--r--src/engine/systems/Music.ts2
-rw-r--r--src/engine/systems/Render.ts8
-rw-r--r--src/engine/utils/modal.ts4
-rw-r--r--src/engine/utils/random.ts2
-rw-r--r--src/interpreter/PeggyParser.js10
-rw-r--r--src/interpreter/interpreter.ts22
-rw-r--r--src/typeshims/rainbowbrackets.d.ts2
32 files changed, 157 insertions, 152 deletions
diff --git a/src/engine/Game.ts b/src/engine/Game.ts
index ab2ea64..fd8be7d 100644
--- a/src/engine/Game.ts
+++ b/src/engine/Game.ts
@@ -48,7 +48,7 @@ export class Game {
public forEachEntityWithComponent(
componentName: string,
- callback: (entity: Entity) => void,
+ callback: (entity: Entity) => void
) {
this.componentEntities.get(componentName)?.forEach((entityId) => {
const entity = this.getEntity(entityId);
@@ -84,12 +84,12 @@ export class Game {
if (!this.componentEntities.has(component.name)) {
this.componentEntities.set(
component.name,
- new Set<string>([entity.id]),
+ new Set<string>([entity.id])
);
return;
}
this.componentEntities.get(component.name)?.add(entity.id);
- }),
+ })
);
this.systemOrder.forEach((systemName) => {
diff --git a/src/engine/TheAbstractionEngine.ts b/src/engine/TheAbstractionEngine.ts
index 29bc553..2c29406 100644
--- a/src/engine/TheAbstractionEngine.ts
+++ b/src/engine/TheAbstractionEngine.ts
@@ -41,7 +41,7 @@ export class TheAbstractionEngine {
{
width: Miscellaneous.GRID_CELL_WIDTH,
height: Miscellaneous.GRID_CELL_HEIGHT,
- },
+ }
),
new GridSpawner(),
new Collision(),
@@ -76,7 +76,7 @@ export class TheAbstractionEngine {
});
this.ctx.canvas.addEventListener("keyup", (e) =>
- input.keyReleased(e.key.toLowerCase()),
+ input.keyReleased(e.key.toLowerCase())
);
this.ctx.canvas.addEventListener("blur", () => input.clearKeys());
diff --git a/src/engine/components/BoundingBox.ts b/src/engine/components/BoundingBox.ts
index d64041f..fd1636f 100644
--- a/src/engine/components/BoundingBox.ts
+++ b/src/engine/components/BoundingBox.ts
@@ -49,8 +49,8 @@ export class BoundingBox extends Component {
const projection = dotProduct(normal, vertex);
return [Math.min(min, projection), Math.max(max, projection)];
},
- [Infinity, -Infinity],
- ),
+ [Infinity, -Infinity]
+ )
);
if (maxThis < minBox || maxBox < minThis) return false;
diff --git a/src/engine/components/GridSpawn.ts b/src/engine/components/GridSpawn.ts
index d2ec898..e0fa250 100644
--- a/src/engine/components/GridSpawn.ts
+++ b/src/engine/components/GridSpawn.ts
@@ -10,7 +10,7 @@ export class GridSpawn extends Component {
constructor(
spawnsLeft: number,
spawner: () => Entity,
- direction = Direction.NONE,
+ direction = Direction.NONE
) {
super(ComponentNames.GridSpawn);
diff --git a/src/engine/components/Highlight.ts b/src/engine/components/Highlight.ts
index 66ec74b..66ada9a 100644
--- a/src/engine/components/Highlight.ts
+++ b/src/engine/components/Highlight.ts
@@ -9,7 +9,7 @@ export class Highlight extends Component {
constructor(
onHighlight: (direction: Direction) => void,
onUnhighlight: () => void,
- isHighlighted: boolean = false,
+ isHighlighted: boolean = false
) {
super(ComponentNames.Highlight);
diff --git a/src/engine/components/Sprite.ts b/src/engine/components/Sprite.ts
index fdf9675..bfb9578 100644
--- a/src/engine/components/Sprite.ts
+++ b/src/engine/components/Sprite.ts
@@ -23,7 +23,7 @@ export class Sprite extends Component implements Renderable {
spriteImgPos: Coord2D,
spriteImgDimensions: Dimension2D,
msPerFrame: number,
- numFrames: number,
+ numFrames: number
) {
super(ComponentNames.Sprite);
@@ -78,7 +78,7 @@ export class Sprite extends Component implements Renderable {
ctx.drawImage(
this.sheet,
...this.getSpriteArgs(),
- ...this.getDrawArgs(drawArgs),
+ ...this.getDrawArgs(drawArgs)
);
if (tint) {
diff --git a/src/engine/components/Text.ts b/src/engine/components/Text.ts
index 94dc7a7..7cc1a50 100644
--- a/src/engine/components/Text.ts
+++ b/src/engine/components/Text.ts
@@ -10,7 +10,7 @@ export class Text extends Component {
text: string,
fillStyle = "white",
font = "25px scientifica",
- textAlign: CanvasTextAlign = "center",
+ textAlign: CanvasTextAlign = "center"
) {
super(ComponentNames.Text);
diff --git a/src/engine/config/assets.ts b/src/engine/config/assets.ts
index fbfab2f..8cf7685 100644
--- a/src/engine/config/assets.ts
+++ b/src/engine/config/assets.ts
@@ -1,7 +1,12 @@
import { type SpriteSpec, SPRITE_SPECS } from ".";
import { SOUND_SPECS, SoundSpec } from "./sounds";
-export const FONT = new FontFace("scientifica", "url(/fonts/scientifica.ttf)");
+const BASE_URL = document.location;
+
+export const FONT = new FontFace(
+ "scientifica",
+ `url(${BASE_URL}/fonts/scientifica.ttf)`
+);
FONT.load().then((font) => {
document.fonts.add(font);
});
@@ -10,26 +15,26 @@ export const IMAGES = new Map<string, HTMLImageElement>();
export const SOUNDS = new Map<string, HTMLAudioElement>();
export const loadSpritesIntoImageElements = (
- spriteSpecs: Partial<SpriteSpec>[],
+ spriteSpecs: Partial<SpriteSpec>[]
): Promise<void>[] => {
const spritePromises: Promise<void>[] = [];
for (const spriteSpec of spriteSpecs) {
if (spriteSpec.sheet) {
const img = new Image();
- img.src = spriteSpec.sheet;
+ img.src = BASE_URL + spriteSpec.sheet;
IMAGES.set(spriteSpec.sheet, img);
spritePromises.push(
new Promise((resolve) => {
img.onload = () => resolve();
- }),
+ })
);
}
if (spriteSpec.states) {
spritePromises.push(
- ...loadSpritesIntoImageElements(Array.from(spriteSpec.states.values())),
+ ...loadSpritesIntoImageElements(Array.from(spriteSpec.states.values()))
);
}
}
@@ -38,13 +43,13 @@ export const loadSpritesIntoImageElements = (
};
export const loadSoundsIntoAudioElements = (
- soundSpecs: SoundSpec[],
+ soundSpecs: SoundSpec[]
): Promise<void>[] => {
const soundPromises: Promise<void>[] = [];
for (const soundSpec of soundSpecs) {
if (soundSpec.url) {
- const promise = fetch(soundSpec.url)
+ const promise = fetch(BASE_URL + soundSpec.url)
.then((response) => response.blob())
.then((blob) => {
const audio = new Audio();
@@ -68,7 +73,7 @@ export const loadSoundsIntoAudioElements = (
if (soundSpec.states) {
soundPromises.push(
- ...loadSoundsIntoAudioElements(Array.from(soundSpec.states.values())),
+ ...loadSoundsIntoAudioElements(Array.from(soundSpec.states.values()))
);
}
}
@@ -80,8 +85,8 @@ export const loadAssets = () =>
Promise.all([
...loadSpritesIntoImageElements(
Array.from(SPRITE_SPECS.keys()).map(
- (key) => SPRITE_SPECS.get(key) as SpriteSpec,
- ),
+ (key) => SPRITE_SPECS.get(key) as SpriteSpec
+ )
),
FONT.load(),
...loadSoundsIntoAudioElements(Array.from(SOUND_SPECS.values())),
diff --git a/src/engine/config/constants.ts b/src/engine/config/constants.ts
index 89f7e92..527bfe1 100644
--- a/src/engine/config/constants.ts
+++ b/src/engine/config/constants.ts
@@ -31,7 +31,7 @@ export namespace KeyConstants {
// value -> [key] from KeyActions
export const ActionKeys: Map<Action, string[]> = Object.keys(
- KeyActions,
+ KeyActions
).reduce((acc: Map<Action, string[]>, key) => {
const action = KeyActions[key.toLowerCase()];
diff --git a/src/engine/config/sprites.ts b/src/engine/config/sprites.ts
index 3614488..f8912d5 100644
--- a/src/engine/config/sprites.ts
+++ b/src/engine/config/sprites.ts
@@ -42,7 +42,7 @@ playerSpriteSpec.states.set(Direction.NONE, {
playerSpriteSpec.states.set(direction, {
sheet: `/assets/lambda/${direction.toLowerCase()}.png`,
});
- },
+ }
);
SPRITE_SPECS.set(Sprites.PLAYER, playerSpriteSpec);
diff --git a/src/engine/entities/Curry.ts b/src/engine/entities/Curry.ts
index 19c5b91..583b9b8 100644
--- a/src/engine/entities/Curry.ts
+++ b/src/engine/entities/Curry.ts
@@ -8,7 +8,7 @@ import { Level, SystemNames } from "../systems";
export class Curry extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.CURRY,
+ Sprites.CURRY
) as SpriteSpec;
constructor(gridPosition: Coord2D) {
@@ -28,8 +28,8 @@ export class Curry extends Entity {
width: Curry.spriteSpec.width,
height: Curry.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(
@@ -41,8 +41,8 @@ export class Curry extends Entity {
height: Curry.spriteSpec.height,
},
Curry.spriteSpec.msPerFrame,
- Curry.spriteSpec.frames,
- ),
+ Curry.spriteSpec.frames
+ )
);
}
diff --git a/src/engine/entities/FunctionApplication.ts b/src/engine/entities/FunctionApplication.ts
index 24e4eec..d907eca 100644
--- a/src/engine/entities/FunctionApplication.ts
+++ b/src/engine/entities/FunctionApplication.ts
@@ -56,8 +56,8 @@ export class FunctionApplication extends Entity {
y: 0,
},
dimension,
- 0,
- ),
+ 0
+ )
);
this.addComponent(new Grid(gridPosition));
@@ -70,8 +70,8 @@ export class FunctionApplication extends Entity {
{ x: 0, y: 0 },
dimension,
FunctionApplication.spriteSpec.msPerFrame,
- FunctionApplication.spriteSpec.frames,
- ),
+ FunctionApplication.spriteSpec.frames
+ )
);
this.addComponent(new Colliding(this.handleCollision.bind(this)));
@@ -94,7 +94,7 @@ export class FunctionApplication extends Entity {
const gridSystem = game.getSystem<GridSystem>(SystemNames.Grid);
const fail = () => {
entityGrid.movingDirection = gridSystem.oppositeDirection(
- entityGrid.previousDirection,
+ entityGrid.previousDirection
);
entity.addComponent(entityGrid);
@@ -103,10 +103,10 @@ export class FunctionApplication extends Entity {
};
const applicationTerm = this.getComponent<LambdaTerm>(
- ComponentNames.LambdaTerm,
+ ComponentNames.LambdaTerm
);
const functionTerm = entity.getComponent<LambdaTerm>(
- ComponentNames.LambdaTerm,
+ ComponentNames.LambdaTerm
);
const newCode = applicationTerm.code.replace("_INPUT", functionTerm.code);
let result: DebrujinifiedLambdaTerm | null = null;
@@ -121,7 +121,7 @@ export class FunctionApplication extends Entity {
const { dimension } = gridSystem;
const nextPosition = gridSystem.getNewGridPosition(
grid.gridPosition,
- entityGrid.previousDirection,
+ entityGrid.previousDirection
);
let applicationResultingEntity: Entity | null = null; // this should be its own function
@@ -142,7 +142,7 @@ export class FunctionApplication extends Entity {
game.removeEntity(entity.id);
if (applicationResultingEntity) {
const grid = applicationResultingEntity.getComponent<Grid>(
- ComponentNames.Grid,
+ ComponentNames.Grid
);
grid.movingDirection = entityGrid.previousDirection;
applicationResultingEntity.addComponent(grid);
diff --git a/src/engine/entities/FunctionBox.ts b/src/engine/entities/FunctionBox.ts
index 0c9123e..dac2174 100644
--- a/src/engine/entities/FunctionBox.ts
+++ b/src/engine/entities/FunctionBox.ts
@@ -24,7 +24,7 @@ import { openModal, closeModal } from "../utils";
export class FunctionBox extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.FUNCTION_BOX,
+ Sprites.FUNCTION_BOX
) as SpriteSpec;
constructor(gridPosition: Coord2D, code: string) {
@@ -40,8 +40,8 @@ export class FunctionBox extends Entity {
width: FunctionBox.spriteSpec.width,
height: FunctionBox.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(new Pushable());
@@ -57,8 +57,8 @@ export class FunctionBox extends Entity {
height: FunctionBox.spriteSpec.height,
},
FunctionBox.spriteSpec.msPerFrame,
- FunctionBox.spriteSpec.frames,
- ),
+ FunctionBox.spriteSpec.frames
+ )
);
this.addComponent(new LambdaTerm(code));
@@ -88,10 +88,10 @@ export const makeLambdaTermHighlightComponent = (entity: Entity) => {
}
const code = entity.getComponent<LambdaTerm>(
- ComponentNames.LambdaTerm,
+ ComponentNames.LambdaTerm
)!.code;
openModal(
- `<div style="text-align:center"><p>${code}</p> <br> <button id="close">Close</button></div>`,
+ `<div style="text-align:center"><p>${code}</p> <br> <button id="close">Close</button></div>`
);
modalOpen = true;
SOUNDS.get(ModalOpen.name)!.play();
diff --git a/src/engine/entities/Grass.ts b/src/engine/entities/Grass.ts
index 70fd601..4fdf1bc 100644
--- a/src/engine/entities/Grass.ts
+++ b/src/engine/entities/Grass.ts
@@ -20,8 +20,8 @@ export class Grass extends Entity {
height: Grass.spriteSpec.height,
},
Grass.spriteSpec.msPerFrame,
- Grass.spriteSpec.frames,
- ),
+ Grass.spriteSpec.frames
+ )
);
}
}
diff --git a/src/engine/entities/Key.ts b/src/engine/entities/Key.ts
index 7168ee8..ec86d0a 100644
--- a/src/engine/entities/Key.ts
+++ b/src/engine/entities/Key.ts
@@ -5,7 +5,7 @@ import { Coord2D } from "../interfaces";
export class Key extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.KEY,
+ Sprites.KEY
) as SpriteSpec;
constructor(gridPosition: Coord2D) {
@@ -25,8 +25,8 @@ export class Key extends Entity {
width: Key.spriteSpec.width,
height: Key.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(
@@ -38,8 +38,8 @@ export class Key extends Entity {
height: Key.spriteSpec.height,
},
Key.spriteSpec.msPerFrame,
- Key.spriteSpec.frames,
- ),
+ Key.spriteSpec.frames
+ )
);
}
}
diff --git a/src/engine/entities/LambdaFactory.ts b/src/engine/entities/LambdaFactory.ts
index 770c096..6f75e90 100644
--- a/src/engine/entities/LambdaFactory.ts
+++ b/src/engine/entities/LambdaFactory.ts
@@ -75,7 +75,7 @@ const syntaxErrorDecoration = Decoration.mark({
export class LambdaFactory extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.LAMBDA_FACTORY,
+ Sprites.LAMBDA_FACTORY
) as SpriteSpec;
private codeEditorState: CodeEditorState | null;
@@ -99,8 +99,8 @@ export class LambdaFactory extends Entity {
width: LambdaFactory.spriteSpec.width,
height: LambdaFactory.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(new Text(spawns.toString()));
@@ -110,8 +110,8 @@ export class LambdaFactory extends Entity {
this.addComponent(
new GridSpawn(
this.spawns,
- () => new FunctionBox({ x: 0, y: 0 }, this.code),
- ),
+ () => new FunctionBox({ x: 0, y: 0 }, this.code)
+ )
);
this.addComponent(new Grid(gridPosition));
@@ -125,15 +125,15 @@ export class LambdaFactory extends Entity {
height: LambdaFactory.spriteSpec.height,
},
LambdaFactory.spriteSpec.msPerFrame,
- LambdaFactory.spriteSpec.frames,
- ),
+ LambdaFactory.spriteSpec.frames
+ )
);
this.addComponent(
new Highlight(
(direction) => this.onHighlight(direction),
- () => this.onUnhighlight(),
- ),
+ () => this.onUnhighlight()
+ )
);
}
@@ -179,10 +179,10 @@ export class LambdaFactory extends Entity {
const codeBox = document.getElementById("code")!;
const syntaxError = document.getElementById("syntax-error")!;
const canvas = document.getElementById(
- Miscellaneous.CANVAS_ID,
+ Miscellaneous.CANVAS_ID
) as HTMLCanvasElement;
const closeButton = document.getElementById(
- "close-modal",
+ "close-modal"
) as HTMLButtonElement;
closeButton.addEventListener("click", () => this.saveAndCloseCodeEditor());
diff --git a/src/engine/entities/LockedDoor.ts b/src/engine/entities/LockedDoor.ts
index aa1f328..3d1fbbe 100644
--- a/src/engine/entities/LockedDoor.ts
+++ b/src/engine/entities/LockedDoor.ts
@@ -21,7 +21,7 @@ import { colors } from "../utils";
export class LockedDoor extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.LOCKED_DOOR,
+ Sprites.LOCKED_DOOR
) as SpriteSpec;
constructor(gridPosition: Coord2D) {
@@ -41,8 +41,8 @@ export class LockedDoor extends Entity {
width: LockedDoor.spriteSpec.width,
height: LockedDoor.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(
@@ -54,8 +54,8 @@ export class LockedDoor extends Entity {
height: LockedDoor.spriteSpec.height,
},
LockedDoor.spriteSpec.msPerFrame,
- LockedDoor.spriteSpec.frames,
- ),
+ LockedDoor.spriteSpec.frames
+ )
);
}
diff --git a/src/engine/entities/Particles.ts b/src/engine/entities/Particles.ts
index 5381b23..d2d4dbb 100644
--- a/src/engine/entities/Particles.ts
+++ b/src/engine/entities/Particles.ts
@@ -86,7 +86,7 @@ class ParticleRenderer extends Component implements Renderable {
particle.dimension.height / 2,
0,
0,
- Math.PI * 2,
+ Math.PI * 2
);
ctx.fill();
} else {
@@ -94,7 +94,7 @@ class ParticleRenderer extends Component implements Renderable {
particle.position.x - particle.dimension.width / 2,
particle.position.y - particle.dimension.height / 2,
particle.dimension.width,
- particle.dimension.height,
+ particle.dimension.height
);
}
}
@@ -119,7 +119,7 @@ export class Particles extends Entity {
const life = this.getComponent<Life>(ComponentNames.Life);
life.alive = false;
this.addComponent(life);
- }),
+ })
);
this.addComponent(
@@ -132,8 +132,8 @@ export class Particles extends Entity {
width: spawnOptions.spawnerDimensions.width,
height: spawnOptions.spawnerDimensions.height,
},
- 0,
- ),
+ 0
+ )
);
}
@@ -141,15 +141,15 @@ export class Particles extends Entity {
const angle = Math.random() * Math.PI * 2;
const speed = normalRandom(
options.particleMeanSpeed,
- options.particleSpeedVariance,
+ options.particleSpeedVariance
);
const life = normalRandom(
options.particleMeanLife,
- options.particleLifeVariance,
+ options.particleLifeVariance
);
const size = normalRandom(
options.particleMeanSize,
- options.particleSizeVariance,
+ options.particleSizeVariance
);
const color =
options.particleColors[
diff --git a/src/engine/entities/Player.ts b/src/engine/entities/Player.ts
index 9e2e1cb..ec88a90 100644
--- a/src/engine/entities/Player.ts
+++ b/src/engine/entities/Player.ts
@@ -12,7 +12,7 @@ import { Coord2D, Direction } from "../interfaces/";
export class Player extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.PLAYER,
+ Sprites.PLAYER
) as SpriteSpec;
constructor(gridPosition: Coord2D) {
@@ -25,8 +25,8 @@ export class Player extends Entity {
y: 0,
},
{ width: Player.spriteSpec.width, height: Player.spriteSpec.height },
- 0,
- ),
+ 0
+ )
);
this.addComponent(new Pushable());
@@ -51,14 +51,14 @@ export class Player extends Entity {
{ x: 0, y: 0 },
{ width: Player.spriteSpec.width, height: Player.spriteSpec.height },
Player.spriteSpec.msPerFrame,
- Player.spriteSpec.frames,
+ Player.spriteSpec.frames
);
facingDirectionComponent.directionSprites.set(direction, sprite);
});
this.addComponent(facingDirectionComponent);
this.addComponent(
- facingDirectionComponent.directionSprites.get(Direction.NONE)!,
+ facingDirectionComponent.directionSprites.get(Direction.NONE)!
); // face no direction by default
}
}
diff --git a/src/engine/entities/Portal.ts b/src/engine/entities/Portal.ts
index a747aa9..221004c 100644
--- a/src/engine/entities/Portal.ts
+++ b/src/engine/entities/Portal.ts
@@ -25,8 +25,8 @@ export class Portal extends Entity {
width: Portal.spriteSpec.width,
height: Portal.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(
@@ -38,8 +38,8 @@ export class Portal extends Entity {
height: Portal.spriteSpec.height,
},
Portal.spriteSpec.msPerFrame,
- Portal.spriteSpec.frames,
- ),
+ Portal.spriteSpec.frames
+ )
);
this.addComponent(new Colliding(this.handleCollision.bind(this)));
diff --git a/src/engine/entities/Wall.ts b/src/engine/entities/Wall.ts
index 621a569..f5beb9c 100644
--- a/src/engine/entities/Wall.ts
+++ b/src/engine/entities/Wall.ts
@@ -5,7 +5,7 @@ import { Coord2D } from "../interfaces";
export class Wall extends Entity {
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
- Sprites.WALL,
+ Sprites.WALL
) as SpriteSpec;
constructor(gridPosition: Coord2D) {
@@ -25,8 +25,8 @@ export class Wall extends Entity {
width: Wall.spriteSpec.width,
height: Wall.spriteSpec.height,
},
- 0,
- ),
+ 0
+ )
);
this.addComponent(
@@ -38,8 +38,8 @@ export class Wall extends Entity {
height: Wall.spriteSpec.height,
},
Wall.spriteSpec.msPerFrame,
- Wall.spriteSpec.frames,
- ),
+ Wall.spriteSpec.frames
+ )
);
}
}
diff --git a/src/engine/systems/Collision.ts b/src/engine/systems/Collision.ts
index 0bc6f5c..7771ba3 100644
--- a/src/engine/systems/Collision.ts
+++ b/src/engine/systems/Collision.ts
@@ -28,7 +28,7 @@ export class Collision extends System {
return;
}
const collidingBox = entity.getComponent<BoundingBox>(
- ComponentNames.BoundingBox,
+ ComponentNames.BoundingBox
);
let collidingGrid = entity.hasComponent(ComponentNames.Grid)
? entity.getComponent<Grid>(ComponentNames.Grid)
@@ -39,7 +39,7 @@ export class Collision extends System {
ComponentNames.BoundingBox,
(otherEntity) => {
const otherBoundingBox = otherEntity.getComponent<BoundingBox>(
- ComponentNames.BoundingBox,
+ ComponentNames.BoundingBox
);
let otherGrid = otherEntity.hasComponent(ComponentNames.Grid)
? otherEntity.getComponent<Grid>(ComponentNames.Grid)
@@ -58,7 +58,7 @@ export class Collision extends System {
if (collidingBox.isCollidingWith(otherBoundingBox)) {
collidingWith.push(otherEntity);
}
- },
+ }
);
for (const collision of collidingWith) {
diff --git a/src/engine/systems/FacingDirection.ts b/src/engine/systems/FacingDirection.ts
index 042484a..ee80c67 100644
--- a/src/engine/systems/FacingDirection.ts
+++ b/src/engine/systems/FacingDirection.ts
@@ -32,16 +32,16 @@ export class FacingDirection extends System {
}
const boundingBox = entity.getComponent<BoundingBox>(
- ComponentNames.BoundingBox,
+ ComponentNames.BoundingBox
)!;
const facingDirection = entity.getComponent<FacingDirectionComponent>(
- ComponentNames.FacingDirection,
+ ComponentNames.FacingDirection
);
const { center } = boundingBox;
const angle = Math.atan2(
mousePosition.y - center.y,
- mousePosition.x - center.x,
+ mousePosition.x - center.x
);
const mouseInBoundingBox =
@@ -58,7 +58,7 @@ export class FacingDirection extends System {
sprite.fillTimingsFromSprite(oldSprite);
entity.addComponent(sprite);
- },
+ }
);
}
}
diff --git a/src/engine/systems/Grid.ts b/src/engine/systems/Grid.ts
index c504bfe..bb67a40 100644
--- a/src/engine/systems/Grid.ts
+++ b/src/engine/systems/Grid.ts
@@ -18,7 +18,7 @@ export class Grid extends System {
constructor(
{ width: columns, height: rows }: Dimension2D,
- dimension: Dimension2D,
+ dimension: Dimension2D
) {
super(SystemNames.Grid);
@@ -50,11 +50,11 @@ export class Grid extends System {
const grid = entity.getComponent<GridComponent>(ComponentNames.Grid)!;
const facingDirection = entity.getComponent<FacingDirection>(
- ComponentNames.FacingDirection,
+ ComponentNames.FacingDirection
)!;
const lookingAt = this.getNewGridPosition(
grid.gridPosition,
- facingDirection.currentDirection,
+ facingDirection.currentDirection
);
if (
facingDirection.currentDirection === Direction.NONE ||
@@ -66,14 +66,14 @@ export class Grid extends System {
this.grid[lookingAt.y][lookingAt.x].forEach((id) => {
highlightableEntities.push([id, facingDirection.currentDirection]);
});
- },
+ }
);
highlightableEntities.forEach(([id, direction]) => {
const entity = game.getEntity(id)!;
if (entity.hasComponent(ComponentNames.Highlight)) {
const highlight = entity.getComponent<Highlight>(
- ComponentNames.Highlight,
+ ComponentNames.Highlight
)!;
highlight.highlight(direction);
}
@@ -82,7 +82,7 @@ export class Grid extends System {
game.forEachEntityWithComponent(ComponentNames.Highlight, (entity) => {
if (!highlightableEntities.find(([id]) => id === entity.id)) {
const highlight = entity.getComponent<Highlight>(
- ComponentNames.Highlight,
+ ComponentNames.Highlight
)!;
highlight.unhighlight();
}
@@ -124,23 +124,23 @@ export class Grid extends System {
const { x, y } = nextGridPosition;
const entities = Array.from(this.grid[y][x]).map(
- (id) => game.getEntity(id)!,
+ (id) => game.getEntity(id)!
);
const collidingEntities = entities.filter((entity) =>
- entity.hasComponent(ComponentNames.Colliding),
+ entity.hasComponent(ComponentNames.Colliding)
);
if (collidingEntities.length > 0) {
// i.e. key going into a door or function going into an application
const allEntitiesInPreviousCellCanCollide = Array.from(
- this.grid[currentPosition.y][currentPosition.x],
+ this.grid[currentPosition.y][currentPosition.x]
)
.map((id) => game.getEntity(id)!)
.every((entity) =>
collidingEntities.every((collidingEntity) =>
- Collision.canCollide(entity.name, collidingEntity.name),
- ),
+ Collision.canCollide(entity.name, collidingEntity.name)
+ )
);
if (allEntitiesInPreviousCellCanCollide) {
break;
@@ -153,7 +153,7 @@ export class Grid extends System {
if (!entity.hasComponent(ComponentNames.Grid)) return false;
const { movingDirection } = entity.getComponent<GridComponent>(
- ComponentNames.Grid,
+ ComponentNames.Grid
)!;
const pushable = entity.hasComponent(ComponentNames.Pushable);
return movingDirection === Direction.NONE && pushable;
@@ -169,7 +169,7 @@ export class Grid extends System {
currentPosition = nextGridPosition;
nextGridPosition = this.getNewGridPosition(
nextGridPosition,
- movingDirection,
+ movingDirection
);
}
@@ -196,7 +196,7 @@ export class Grid extends System {
}
const boundingBox = entity.getComponent<BoundingBox>(
- ComponentNames.BoundingBox,
+ ComponentNames.BoundingBox
)!;
boundingBox.center = this.gridToScreenPosition(grid.gridPosition);
boundingBox.dimension = this.dimension;
@@ -210,7 +210,7 @@ export class Grid extends System {
private updateMovingEntities(
dt: number,
game: Game,
- velocity = PhysicsConstants.GRID_MOVEMENT_VELOCITY,
+ velocity = PhysicsConstants.GRID_MOVEMENT_VELOCITY
) {
game.forEachEntityWithComponent(ComponentNames.Grid, (entity) => {
const grid = entity.getComponent<GridComponent>(ComponentNames.Grid)!;
@@ -221,12 +221,12 @@ export class Grid extends System {
grid.previousDirection = grid.movingDirection;
const boundingBox = entity.getComponent<BoundingBox>(
- ComponentNames.BoundingBox,
+ ComponentNames.BoundingBox
)!;
const newGridPosition = this.getNewGridPosition(
grid.gridPosition,
- grid.movingDirection,
+ grid.movingDirection
);
if (this.isOutOfBounds(newGridPosition)) {
grid.movingDirection = Direction.NONE;
@@ -255,7 +255,7 @@ export class Grid extends System {
const passedCenter = this.isEntityPastCenterWhenMoving(
grid.movingDirection,
newGridPosition,
- nextPosition,
+ nextPosition
);
if (passedCenter) {
@@ -319,7 +319,7 @@ export class Grid extends System {
private isEntityPastCenterWhenMoving(
direction: Direction,
gridPosition: Coord2D,
- entityPosition: Coord2D,
+ entityPosition: Coord2D
) {
const { x, y } = this.gridToScreenPosition(gridPosition);
switch (direction) {
@@ -368,7 +368,7 @@ export class Grid extends System {
cell.delete(id);
}
}
- }),
+ })
);
movedEntities.forEach((id) => {
const entity = game.getEntity(id)!;
diff --git a/src/engine/systems/Input.ts b/src/engine/systems/Input.ts
index c527f29..9199c89 100644
--- a/src/engine/systems/Input.ts
+++ b/src/engine/systems/Input.ts
@@ -32,20 +32,20 @@ export class Input extends System {
public update(_dt: number, game: Game) {
game.forEachEntityWithComponent(ComponentNames.Control, (entity) =>
- this.handleMovement(entity, game),
+ this.handleMovement(entity, game)
);
game.forEachEntityWithComponent(ComponentNames.Interactable, (entity) =>
- this.handleInteraction(entity),
+ this.handleInteraction(entity)
);
}
private handleInteraction(entity: Entity) {
const interactable = entity.getComponent<Interactable>(
- ComponentNames.Interactable,
+ ComponentNames.Interactable
);
const interact = this.hasSomeKey(
- KeyConstants.ActionKeys.get(Action.INTERACT),
+ KeyConstants.ActionKeys.get(Action.INTERACT)
);
if (!interact) {
@@ -54,13 +54,13 @@ export class Input extends System {
interactable.interact();
KeyConstants.ActionKeys.get(Action.INTERACT)!.forEach((key) =>
- this.keyReleased(key),
+ this.keyReleased(key)
);
}
public handleMovement(entity: Entity, game: Game) {
const controlComponent = entity.getComponent<Control>(
- ComponentNames.Control,
+ ComponentNames.Control
);
if (!controlComponent.isControllable) return;
@@ -85,22 +85,22 @@ export class Input extends System {
if (moveUp) {
gridComponent.movingDirection = Direction.UP;
KeyConstants.ActionKeys.get(Action.MOVE_UP)!.forEach((key) =>
- this.keyReleased(key),
+ this.keyReleased(key)
);
} else if (moveLeft) {
gridComponent.movingDirection = Direction.LEFT;
KeyConstants.ActionKeys.get(Action.MOVE_LEFT)!.forEach((key) =>
- this.keyReleased(key),
+ this.keyReleased(key)
);
} else if (moveRight) {
gridComponent.movingDirection = Direction.RIGHT;
KeyConstants.ActionKeys.get(Action.MOVE_RIGHT)!.forEach((key) =>
- this.keyReleased(key),
+ this.keyReleased(key)
);
} else if (moveDown) {
gridComponent.movingDirection = Direction.DOWN;
KeyConstants.ActionKeys.get(Action.MOVE_DOWN)!.forEach((key) =>
- this.keyReleased(key),
+ this.keyReleased(key)
);
}
diff --git a/src/engine/systems/Music.ts b/src/engine/systems/Music.ts
index 6e2004d..bdfa790 100644
--- a/src/engine/systems/Music.ts
+++ b/src/engine/systems/Music.ts
@@ -9,7 +9,7 @@ export class Music extends System {
super(SystemNames.Music);
this.songs = Array.from(GameMusic.states!.values()).map(
- (state) => state.name,
+ (state) => state.name
);
}
diff --git a/src/engine/systems/Render.ts b/src/engine/systems/Render.ts
index 2dd35e2..c730cec 100644
--- a/src/engine/systems/Render.ts
+++ b/src/engine/systems/Render.ts
@@ -26,7 +26,7 @@ export class Render extends System {
sprite.update(dt);
const boundingBox = entity.getComponent<BoundingBox>(
- ComponentNames.BoundingBox,
+ ComponentNames.BoundingBox
);
// don't render if we're outside the screen
@@ -34,12 +34,12 @@ export class Render extends System {
clamp(
boundingBox.center.y,
-boundingBox.dimension.height / 2,
- this.ctx.canvas.height + boundingBox.dimension.height / 2,
+ this.ctx.canvas.height + boundingBox.dimension.height / 2
) != boundingBox.center.y ||
clamp(
boundingBox.center.x,
-boundingBox.dimension.width / 2,
- this.ctx.canvas.width + boundingBox.dimension.width / 2,
+ this.ctx.canvas.width + boundingBox.dimension.width / 2
) != boundingBox.center.x
) {
return;
@@ -52,7 +52,7 @@ export class Render extends System {
};
if (entity.hasComponent(ComponentNames.Highlight)) {
const highlight = entity.getComponent<Highlight>(
- ComponentNames.Highlight,
+ ComponentNames.Highlight
);
drawArgs.tint = highlight.isHighlighted ? "red" : undefined;
}
diff --git a/src/engine/utils/modal.ts b/src/engine/utils/modal.ts
index a378821..02f8ebf 100644
--- a/src/engine/utils/modal.ts
+++ b/src/engine/utils/modal.ts
@@ -5,7 +5,7 @@ let modalOpen = false;
export const openModal = (
content: string,
id = Miscellaneous.MODAL_ID,
- contentId = Miscellaneous.MODAL_CONTENT_ID,
+ contentId = Miscellaneous.MODAL_CONTENT_ID
) => {
const modal = document.getElementById(id);
const modalContent = document.getElementById(contentId);
@@ -22,7 +22,7 @@ export const openModal = (
export const closeModal = (
id = Miscellaneous.MODAL_ID,
- contentId = Miscellaneous.MODAL_CONTENT_ID,
+ contentId = Miscellaneous.MODAL_CONTENT_ID
) => {
const modal = document.getElementById(id);
const modalContent = document.getElementById(contentId);
diff --git a/src/engine/utils/random.ts b/src/engine/utils/random.ts
index 3d9d8b8..0270f60 100644
--- a/src/engine/utils/random.ts
+++ b/src/engine/utils/random.ts
@@ -4,6 +4,6 @@ export const normalRandom = (mean: number, stdDev: number, maxStdDevs = 2) => {
mean + stdDev * Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
return Math.min(
mean + maxStdDevs * stdDev,
- Math.max(mean - maxStdDevs * stdDev, normal),
+ Math.max(mean - maxStdDevs * stdDev, normal)
);
};
diff --git a/src/interpreter/PeggyParser.js b/src/interpreter/PeggyParser.js
index 5671d91..121cf9d 100644
--- a/src/interpreter/PeggyParser.js
+++ b/src/interpreter/PeggyParser.js
@@ -226,7 +226,7 @@ export default (function () {
["0", "9"],
],
false,
- false,
+ false
);
var peg$e1 = peg$literalExpectation("(", false);
var peg$e2 = peg$literalExpectation(")", false);
@@ -260,7 +260,7 @@ export default (function () {
if (options.startRule) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error(
- "Can't start parsing from rule \"" + options.startRule + '".',
+ "Can't start parsing from rule \"" + options.startRule + '".'
);
}
@@ -296,7 +296,7 @@ export default (function () {
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
input.substring(peg$savedPos, peg$currPos),
- location,
+ location
);
}
@@ -417,7 +417,7 @@ export default (function () {
peg$SyntaxError.buildMessage(expected, found),
expected,
found,
- location,
+ location
);
}
@@ -883,7 +883,7 @@ export default (function () {
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
peg$maxFailPos < input.length
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos),
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
);
}
}
diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts
index 4599c46..c546bd2 100644
--- a/src/interpreter/interpreter.ts
+++ b/src/interpreter/interpreter.ts
@@ -32,7 +32,7 @@ export type DebrujinifiedLambdaTerm =
export const debrujinify = (
term: LambdaTerm,
- symbolTable: SymbolTable,
+ symbolTable: SymbolTable
): DebrujinifiedLambdaTerm => {
if (isVariable(term)) {
if (!symbolTable.has(term)) {
@@ -65,14 +65,14 @@ export const debrujinify = (
}
throw new InvalidLambdaTermError(
- `Invalid lambda term: ${JSON.stringify(term)}`,
+ `Invalid lambda term: ${JSON.stringify(term)}`
);
};
export const substitute = (
inTerm: DebrujinifiedLambdaTerm,
index: number,
- withTerm: DebrujinifiedLambdaTerm,
+ withTerm: DebrujinifiedLambdaTerm
): DebrujinifiedLambdaTerm => {
if ("index" in inTerm) {
if (inTerm.index > index) {
@@ -108,13 +108,13 @@ export const substitute = (
}
throw new InvalidLambdaTermError(
- `Invalid lambda term: ${JSON.stringify(inTerm)}`,
+ `Invalid lambda term: ${JSON.stringify(inTerm)}`
);
};
export const adjustIndices = (
term: DebrujinifiedLambdaTerm,
- delta: number,
+ delta: number
): DebrujinifiedLambdaTerm => {
if ("index" in term) {
return {
@@ -146,12 +146,12 @@ export const adjustIndices = (
}
throw new InvalidLambdaTermError(
- `Invalid lambda term: ${JSON.stringify(term)}`,
+ `Invalid lambda term: ${JSON.stringify(term)}`
);
};
export const betaReduce = (
- term: DebrujinifiedLambdaTerm,
+ term: DebrujinifiedLambdaTerm
): DebrujinifiedLambdaTerm => {
if ("index" in term) {
return term;
@@ -194,7 +194,7 @@ export const betaReduce = (
}
throw new InvalidLambdaTermError(
- `Invalid lambda term: ${JSON.stringify(term)}`,
+ `Invalid lambda term: ${JSON.stringify(term)}`
);
};
@@ -214,7 +214,7 @@ export const emitDebrujin = (term: DebrujinifiedLambdaTerm): string => {
}
throw new InvalidLambdaTermError(
- `Invalid lambda term: ${JSON.stringify(term)}`,
+ `Invalid lambda term: ${JSON.stringify(term)}`
);
};
@@ -225,7 +225,7 @@ export const emitNamed = (term: DebrujinifiedLambdaTerm): string => {
if ("abstraction" in term) {
return `(λ (${term.abstraction.param}) . ${emitNamed(
- term.abstraction.body,
+ term.abstraction.body
)})`;
}
@@ -241,7 +241,7 @@ export const emitNamed = (term: DebrujinifiedLambdaTerm): string => {
export const interpret = (
term: string,
symbolTable = new SymbolTable(),
- allowUnderscores = false,
+ allowUnderscores = false
): DebrujinifiedLambdaTerm => {
const ast = parse(term, allowUnderscores);
const debrujined = debrujinify(ast, symbolTable);
diff --git a/src/typeshims/rainbowbrackets.d.ts b/src/typeshims/rainbowbrackets.d.ts
index ac9a2ff..eabff8d 100644
--- a/src/typeshims/rainbowbrackets.d.ts
+++ b/src/typeshims/rainbowbrackets.d.ts
@@ -1 +1 @@
-declare module 'rainbowbrackets';
+declare module "rainbowbrackets";