1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { FunctionApplication, Grass, LambdaFactory, Player } from "../entities";
import { Game } from "../Game";
import { Grid, SystemNames } from "../systems";
import { normalRandom } from "../utils";
import { Level } from "./Level";
import { LevelNames } from "./LevelNames";
export class ChurchNumeralsOne extends Level {
constructor() {
super(LevelNames.ChurchNumeralsOne);
}
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),
),
});
});
[
...grasses,
new LambdaFactory({ x: 1, y: 1 }, "(\\ (f) . (\\ (x) . (f f x)))", 1),
new FunctionApplication(
{ x: 2, y: 2 },
"(_INPUT ((_SPAWN _RIGHT) _KEY))",
),
new FunctionApplication(
{ x: 3, y: 3 },
"(_INPUT _EMPTY)",
),
new Player({ x: 0, y: 0 }),
].forEach((e) => game.addEntity(e));
}
}
|