summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-12 19:10:55 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-12 19:10:55 -0600
commit3d18643be057ed1fe1a5a0e6b4d8da918488b229 (patch)
treefd77d7d4f422adbc94cee06b59a580f2bbee8693
parentde4f3fd2fe45478ffabc84f055592e11b119d0a4 (diff)
downloadthe-abstraction-engine-3d18643be057ed1fe1a5a0e6b4d8da918488b229.tar.gz
the-abstraction-engine-3d18643be057ed1fe1a5a0e6b4d8da918488b229.zip
add grass
-rw-r--r--public/assets/sign.pngbin2015 -> 2240 bytes
-rw-r--r--src/engine/TheAbstractionEngine.ts2
-rw-r--r--src/engine/config/sounds.ts8
-rw-r--r--src/engine/entities/Grass.ts21
-rw-r--r--src/engine/levels/Tutorial.ts32
-rw-r--r--src/engine/systems/Grid.ts7
6 files changed, 59 insertions, 11 deletions
diff --git a/public/assets/sign.png b/public/assets/sign.png
index 006badd..f9e0c6f 100644
--- a/public/assets/sign.png
+++ b/public/assets/sign.png
Binary files 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<Grid>(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<br><br>modify the produced term by interacting from the top or bottom ↕️<br><br>then produce the term by pressing the button on the left or right ↔️<br><br>",
+ { x: 4, y: 3 },
+ ),
+ new Sign(
+ "this is a Term Application; interact to view its code<br><br>push the term ➡️ created by the factory any direction into the Application to produce a new one 💭<br><br>. _INPUT is the term replaced by the pushed term<br><br>. 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);