diff options
author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-03-01 15:31:27 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-03-01 15:31:27 -0700 |
commit | 07f508365f619d6bfe0a074dcf98c5ae8db17f08 (patch) | |
tree | 16b2a072998452ad72529e3d617f5c4a2df63c0c /src/engine/levels/CarCadr.ts | |
parent | 309ed20627ed798c464a9f97d9c32ceb1a314595 (diff) | |
download | the-abstraction-engine-07f508365f619d6bfe0a074dcf98c5ae8db17f08.tar.gz the-abstraction-engine-07f508365f619d6bfe0a074dcf98c5ae8db17f08.zip |
add carcadr level
Diffstat (limited to 'src/engine/levels/CarCadr.ts')
-rw-r--r-- | src/engine/levels/CarCadr.ts | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/engine/levels/CarCadr.ts b/src/engine/levels/CarCadr.ts new file mode 100644 index 0000000..e3d1eb9 --- /dev/null +++ b/src/engine/levels/CarCadr.ts @@ -0,0 +1,60 @@ +import { Level, LevelNames } from "."; +import { Game } from ".."; +import { + Curry, + FunctionApplication, + Grass, + LambdaFactory, + LockedDoor, + Player, + Wall, +} from "../entities"; +import { Grid, SystemNames } from "../systems"; +import { normalRandom } from "../utils"; + +export class CarCadr extends Level { + constructor() { + super(LevelNames.CarCadr); + } + + 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 = [ + ...grasses, + new Player({ x: 9, y: 5 }), + new Wall({ x: 4, y: 3 }), + new Wall({ x: 4, y: 4 }), + new LambdaFactory({ x: 6, y: 4 }, "(\\ (x) . x)", 1), + new FunctionApplication({ x: 5, y: 5 }, "(_INPUT _KEY)"), + new Wall({ x: 4, y: 5 }), + new Wall({ x: 6, y: 5 }), + new FunctionApplication({ x: 4, y: 6 }, "(_INPUT _NULL)"), + new Wall({ x: 6, y: 7 }), + new Wall({ x: 5, y: 7 }), + new Wall({ x: 4, y: 7 }), + new LockedDoor({ x: 3, y: 8 }), + new Curry({ x: 3, y: 9 }), + new Wall({ x: 2, y: 9 }), + new Wall({ x: 4, y: 9 }), + new Wall({ x: 3, y: 10 }), + ]; + + entities.forEach((entity) => game.addEntity(entity)); + } +}
\ No newline at end of file |