diff --git a/public/assets/sign.png b/public/assets/sign.png index 006badd..f9e0c6f 100644 Binary files a/public/assets/sign.png and b/public/assets/sign.png differ diff --git a/src/engine/TheAbstractionEngine.ts b/src/engine/TheAbstractionEngine.ts index 0dc75aa..d130a6f 100644 --- a/src/engine/TheAbstractionEngine.ts +++ b/src/engine/TheAbstractionEngine.ts @@ -46,7 +46,7 @@ export class TheAbstractionEngine { new GridSpawner(), new Collision(), new Life(), - new Music(), + // new Music(), new Render(this.ctx), ].forEach((system) => this.game.addSystem(system)); } diff --git a/src/engine/config/sounds.ts b/src/engine/config/sounds.ts index d6c564f..5900ef0 100644 --- a/src/engine/config/sounds.ts +++ b/src/engine/config/sounds.ts @@ -22,29 +22,31 @@ export const LambdaTransformSound: SoundSpec = { export const LambdaSave: SoundSpec = { name: "lambdaSave", url: "/assets/sound/lambda_save.wav", + volume: 0.3, }; export const Failure: SoundSpec = { name: "failure", url: "/assets/sound/failure.wav", - volume: 0.5, + volume: 0.3, }; export const ModalOpen: SoundSpec = { name: "modalOpen", url: "/assets/sound/modal_open.wav", - volume: 0.5, + volume: 0.3, }; export const ModalClose: SoundSpec = { name: "modalClose", url: "/assets/sound/modal_close.wav", - volume: 0.5, + volume: 0.3, }; export const KeyOpen: SoundSpec = { name: "keyOpen", url: "/assets/sound/keyopen.wav", + volume: 0.5, }; export const Music: SoundSpec = { diff --git a/src/engine/entities/Grass.ts b/src/engine/entities/Grass.ts index 70fd601..75c03f7 100644 --- a/src/engine/entities/Grass.ts +++ b/src/engine/entities/Grass.ts @@ -1,5 +1,5 @@ import { Entity, EntityNames } from "."; -import { Grid, Sprite } from "../components"; +import { BoundingBox, Grid, Sprite } from "../components"; import { IMAGES, SPRITE_SPECS, SpriteSpec, Sprites } from "../config"; import { Coord2D } from "../interfaces"; @@ -11,17 +11,28 @@ export class Grass extends Entity { this.addComponent(new Grid(gridPosition)); + const dimensions = { + width: Grass.spriteSpec.width, + height: Grass.spriteSpec.height, + }; this.addComponent( new Sprite( IMAGES.get(Grass.spriteSpec.sheet)!, { x: 0, y: 0 }, - { - width: Grass.spriteSpec.width, - height: Grass.spriteSpec.height, - }, + dimensions, Grass.spriteSpec.msPerFrame, Grass.spriteSpec.frames, ), ); + + this.addComponent( + new BoundingBox( + { + x: 0, + y: 0, + }, + dimensions, + ), + ); } } diff --git a/src/engine/levels/Tutorial.ts b/src/engine/levels/Tutorial.ts index b720346..a8ba8d0 100644 --- a/src/engine/levels/Tutorial.ts +++ b/src/engine/levels/Tutorial.ts @@ -3,21 +3,49 @@ import { Game } from ".."; import { Curry, FunctionApplication, + Grass, LambdaFactory, LockedDoor, Player, Sign, Wall, } from "../entities"; +import { Grid, SystemNames } from "../systems"; +import { normalRandom } from "../utils"; export class Tutorial extends Level { constructor() { super(LevelNames.Tutorial); } - public init(game: Game): void { + public init(game: Game) { + const grid = game.getSystem(SystemNames.Grid); + const dimensions = grid.getGridDimensions(); + + const grasses = Array.from({ length: dimensions.width }) + .fill(0) + .map(() => { + // random grass + return new Grass({ + x: Math.floor( + normalRandom(dimensions.width / 2, dimensions.width / 4, 1.5), + ), + y: Math.floor( + normalRandom(dimensions.height / 2, dimensions.height / 4, 1.5), + ), + }); + }); + const entities = [ - new Sign("TODO: Explain entities", { x: 4, y: 3 }), + ...grasses, + new Sign( + "this is a Lambda Factory

modify the produced term by interacting from the top or bottom ↕️

then produce the term by pressing the button on the left or right ↔️

", + { x: 4, y: 3 }, + ), + new Sign( + "this is a Term Application; interact to view its code

push the term ➡️ created by the factory any direction into the Application to produce a new one 💭

. _INPUT is the term replaced by the pushed term

. in this case _KEY is applied to the function to make a new KEY! 🔑", + { x: 4, y: 6 }, + ), new Wall({ x: 10, y: 9 }), new Wall({ x: 10, y: 11 }), new Wall({ x: 11, y: 10 }), diff --git a/src/engine/systems/Grid.ts b/src/engine/systems/Grid.ts index c504bfe..3c0e995 100644 --- a/src/engine/systems/Grid.ts +++ b/src/engine/systems/Grid.ts @@ -28,6 +28,13 @@ export class Grid extends System { .map(() => new Array(columns).fill(null).map(() => new Set())); } + public getGridDimensions() { + return { + width: this.grid[0].length, + height: this.grid.length, + }; + } + public update(dt: number, game: Game) { this.putUninitializedEntitiesInGrid(game); this.rebuildGrid(game);