From de4f3fd2fe45478ffabc84f055592e11b119d0a4 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Mon, 11 Mar 2024 16:35:51 -0600 Subject: [PATCH] prettier, fix assets and css --- public/assets/sign.png | Bin 996 -> 2015 bytes src/css/style.css | 4 --- src/engine/Game.ts | 6 ++-- src/engine/TheAbstractionEngine.ts | 4 +-- src/engine/components/BoundingBox.ts | 4 +-- src/engine/components/GridSpawn.ts | 2 +- src/engine/components/Highlight.ts | 2 +- src/engine/components/Sprite.ts | 4 +-- src/engine/components/Text.ts | 2 +- src/engine/config/assets.ts | 16 ++++----- src/engine/config/constants.ts | 2 +- src/engine/config/sprites.ts | 2 +- src/engine/entities/Curry.ts | 10 +++--- src/engine/entities/FunctionApplication.ts | 18 +++++----- src/engine/entities/FunctionBox.ts | 14 ++++---- src/engine/entities/Grass.ts | 4 +-- src/engine/entities/Key.ts | 10 +++--- src/engine/entities/LambdaFactory.ts | 22 ++++++------ src/engine/entities/LockedDoor.ts | 10 +++--- src/engine/entities/Particles.ts | 16 ++++----- src/engine/entities/Player.ts | 10 +++--- src/engine/entities/Portal.ts | 8 ++--- src/engine/entities/Sign.ts | 10 +++--- src/engine/entities/Wall.ts | 10 +++--- src/engine/systems/Collision.ts | 6 ++-- src/engine/systems/FacingDirection.ts | 8 ++--- src/engine/systems/Grid.ts | 40 ++++++++++----------- src/engine/systems/Input.ts | 20 +++++------ src/engine/systems/Music.ts | 2 +- src/engine/systems/Render.ts | 8 ++--- src/engine/utils/modal.ts | 4 +-- src/engine/utils/random.ts | 2 +- src/interpreter/PeggyParser.js | 10 +++--- src/interpreter/interpreter.ts | 22 ++++++------ src/interpreter/parser.ts | 2 +- 35 files changed, 155 insertions(+), 159 deletions(-) diff --git a/public/assets/sign.png b/public/assets/sign.png index a778b3bc151924c9579e6d867f4b6ded03764720..006badd03725354053d106879ecb738880ffb949 100644 GIT binary patch delta 2002 zcmV;@2QB#I2j35nBYy{sNklw{79kIi5H3VTND9+fTmq?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ZB`{R{z4mOyj4 z|8^q*JeGP800MkjpsE782{78G$9oQaHUolxtXoFT`X2%~6#xPhC%|kquXM9lwNoJN z)`--hmKz_oU(-)BnzX$0^ZEW5wvV68oSecAJC__X%y z^<~d5;eUew&OJc3qq64L0$gj)T34@m%M!rqSZlvt4r}#4R$SJ8t=83R9u3#>3ZNNa zU$b7dNzDof@c;d!oA_Fk%^|Y}MDz-GbX-;dN9T>=h>nY{Gi#g`2L#x8z-qWG$F-U_ ziX%F%)w)~FW5pr90eZA!Ovx}=>&%+Bm4ma78-J_dhX6uERtbRKiDk3|;Qj_cufUN0 zM>1fqy$bmIT;S{Fe+b}ANf4ko0lbpwjIZDBy)t@qefx3VjHUfA`1^dJ$gKbn;Mf8X zpzX85y%In(0%#dc%9y=?de@iT-+F;6dmUHJKMH;ba8U$|5&##$ALczo5a6N+fB>9e^D0vH3gRW}F#0jT|{{V%Wm zQGiw{-8l~mfC8WZC;$q;=?|wrPVr3X-bj5DoPvT$u|UuQ5FltchOJ=%2(X49K@qe7 x1PB_AVQW|b0<7UjPy{Ui0fL5O*cul20L@HjeF6LMUH||907*qoM6N<$f&f;EuXq3e diff --git a/src/css/style.css b/src/css/style.css index 1b98555..b9a00bb 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -57,10 +57,6 @@ a:visited { border-radius: 0.5rem; } -.content { - max-height: 90vh; -} - .footer { border-top: 2px solid var(--yellow); border-radius: 0.5rem; diff --git a/src/engine/Game.ts b/src/engine/Game.ts index fd8be7d..ab2ea64 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([entity.id]) + new Set([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 4a0effa..0dc75aa 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 fd1636f..d64041f 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 e0fa250..d2ec898 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 66ada9a..66ec74b 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 bfb9578..fdf9675 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 7cc1a50..94dc7a7 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 5c07c1d..c7d6a0e 100644 --- a/src/engine/config/assets.ts +++ b/src/engine/config/assets.ts @@ -6,7 +6,7 @@ BASE_URL = BASE_URL.endsWith("/") ? BASE_URL.slice(0, -1) : BASE_URL; export const FONT = new FontFace( "scientifica", - `url(${BASE_URL}/fonts/scientifica.ttf)` + `url(${BASE_URL}/fonts/scientifica.ttf)`, ); FONT.load().then((font) => { document.fonts.add(font); @@ -16,7 +16,7 @@ export const IMAGES = new Map(); export const SOUNDS = new Map(); export const loadSpritesIntoImageElements = ( - spriteSpecs: Partial[] + spriteSpecs: Partial[], ): Promise[] => { const spritePromises: Promise[] = []; @@ -29,13 +29,13 @@ export const loadSpritesIntoImageElements = ( 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())), ); } } @@ -44,7 +44,7 @@ export const loadSpritesIntoImageElements = ( }; export const loadSoundsIntoAudioElements = ( - soundSpecs: SoundSpec[] + soundSpecs: SoundSpec[], ): Promise[] => { const soundPromises: Promise[] = []; @@ -74,7 +74,7 @@ export const loadSoundsIntoAudioElements = ( if (soundSpec.states) { soundPromises.push( - ...loadSoundsIntoAudioElements(Array.from(soundSpec.states.values())) + ...loadSoundsIntoAudioElements(Array.from(soundSpec.states.values())), ); } } @@ -86,8 +86,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 527bfe1..89f7e92 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 = Object.keys( - KeyActions + KeyActions, ).reduce((acc: Map, key) => { const action = KeyActions[key.toLowerCase()]; diff --git a/src/engine/config/sprites.ts b/src/engine/config/sprites.ts index 481dbb9..005e1b1 100644 --- a/src/engine/config/sprites.ts +++ b/src/engine/config/sprites.ts @@ -43,7 +43,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 583b9b8..19c5b91 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 175534c..a266941 100644 --- a/src/engine/entities/FunctionApplication.ts +++ b/src/engine/entities/FunctionApplication.ts @@ -62,8 +62,8 @@ export class FunctionApplication extends Entity { y: 0, }, dimension, - 0 - ) + 0, + ), ); this.addComponent(new Grid(gridPosition)); @@ -76,8 +76,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))); @@ -100,7 +100,7 @@ export class FunctionApplication extends Entity { const gridSystem = game.getSystem(SystemNames.Grid); const fail = () => { entityGrid.movingDirection = gridSystem.oppositeDirection( - entityGrid.previousDirection + entityGrid.previousDirection, ); entity.addComponent(entityGrid); @@ -109,10 +109,10 @@ export class FunctionApplication extends Entity { }; const applicationTerm = this.getComponent( - ComponentNames.LambdaTerm + ComponentNames.LambdaTerm, ); const functionTerm = entity.getComponent( - ComponentNames.LambdaTerm + ComponentNames.LambdaTerm, ); const newCode = applicationTerm.code.replace("_INPUT", functionTerm.code); @@ -128,7 +128,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 @@ -150,7 +150,7 @@ export class FunctionApplication extends Entity { game.removeEntity(entity.id); if (applicationResultingEntity) { const grid = applicationResultingEntity.getComponent( - 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 7b70567..4878c98 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)); @@ -69,7 +69,7 @@ export class FunctionBox extends Entity { export const makeLambdaTermHighlightComponent = ( entity: Entity, - text?: string + text?: string, ) => { const onUnhighlight = () => { closeModal(); @@ -94,7 +94,7 @@ export const makeLambdaTermHighlightComponent = ( text ?? entity.getComponent(ComponentNames.LambdaTerm)!.code; openModal( - `

${code}


` + `

${code}


`, ); modalOpen = true; SOUNDS.get(ModalOpen.name)!.play(); diff --git a/src/engine/entities/Grass.ts b/src/engine/entities/Grass.ts index 4fdf1bc..70fd601 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 ec86d0a..7168ee8 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 6f75e90..770c096 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 3d1fbbe..aa1f328 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 d2d4dbb..5381b23 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(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 ec88a90..9e2e1cb 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 221004c..a747aa9 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/Sign.ts b/src/engine/entities/Sign.ts index a11fba6..45f2986 100644 --- a/src/engine/entities/Sign.ts +++ b/src/engine/entities/Sign.ts @@ -5,7 +5,7 @@ import { Coord2D } from "../interfaces"; export class Sign extends Entity { private static spriteSpec: SpriteSpec = SPRITE_SPECS.get( - Sprites.SIGN + Sprites.SIGN, ) as SpriteSpec; private text: string; @@ -25,8 +25,8 @@ export class Sign extends Entity { { x: 0, y: 0 }, dimension, Sign.spriteSpec.msPerFrame, - Sign.spriteSpec.frames - ) + Sign.spriteSpec.frames, + ), ); this.addComponent( @@ -36,8 +36,8 @@ export class Sign extends Entity { y: 0, }, dimension, - 0 - ) + 0, + ), ); this.addComponent(new Grid(gridPosition)); diff --git a/src/engine/entities/Wall.ts b/src/engine/entities/Wall.ts index f5beb9c..621a569 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 7771ba3..0bc6f5c 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( - ComponentNames.BoundingBox + ComponentNames.BoundingBox, ); let collidingGrid = entity.hasComponent(ComponentNames.Grid) ? entity.getComponent(ComponentNames.Grid) @@ -39,7 +39,7 @@ export class Collision extends System { ComponentNames.BoundingBox, (otherEntity) => { const otherBoundingBox = otherEntity.getComponent( - ComponentNames.BoundingBox + ComponentNames.BoundingBox, ); let otherGrid = otherEntity.hasComponent(ComponentNames.Grid) ? otherEntity.getComponent(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 ee80c67..042484a 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( - ComponentNames.BoundingBox + ComponentNames.BoundingBox, )!; const facingDirection = entity.getComponent( - 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 bb67a40..c504bfe 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(ComponentNames.Grid)!; const facingDirection = entity.getComponent( - 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( - 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( - 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( - 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( - 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(ComponentNames.Grid)!; @@ -221,12 +221,12 @@ export class Grid extends System { grid.previousDirection = grid.movingDirection; const boundingBox = entity.getComponent( - 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 9199c89..c527f29 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( - 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( - 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 bdfa790..6e2004d 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 c730cec..2dd35e2 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( - 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( - 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 02f8ebf..a378821 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 0270f60..3d9d8b8 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 f5376b3..363f60b 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 c546bd2..4599c46 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/interpreter/parser.ts b/src/interpreter/parser.ts index 930b953..99a9038 100644 --- a/src/interpreter/parser.ts +++ b/src/interpreter/parser.ts @@ -33,7 +33,7 @@ export const isVariable = (term: LambdaTerm): term is Variable => { export const parse = ( term: string, allowUnderscores = false, - library = false + library = false, ) => { return peggyParser.parse(term, { peg$library: library, allowUnderscores }); };