-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlevel2.js
103 lines (94 loc) · 3.68 KB
/
level2.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//restart the world with new random init
export function initStacks() {
Matter.World.clear(engine.world);
state = getInitialState();
let reactor_left_wall = FUEL_SIZE * 4;
let drop_height = 450;
let reactor_width = FUEL_SIZE * 9.2;
let reactor_center = reactor_left_wall + reactor_width / 2;
let poison_stack = Matter.Composites.stack(800 + reactor_left_wall, HEIGHT - drop_height, 1, 10, 0, 0, function (x, y) {
let m = make_poison(x, y);
state.poisons.push(m);
state.core_materials.push(m);
return m;
});
let moderator_stack = Matter.Composites.stack(700 + reactor_left_wall, HEIGHT - drop_height, 1, 10, 0, 0, function (x, y) {
let m = make_moderator(x, y);
state.moderators.push(m);
state.core_materials.push(m);
return m;
});
let reflector_left = Matter.Composites.stack(10 + reactor_left_wall, HEIGHT - drop_height, 2, 8, 0, 0, function (x, y) {
let m = make_reflector(x, y);
state.reflectors.push(m);
state.core_materials.push(m);
return m;
});
let reflector_right = Matter.Composites.stack(reactor_left_wall + reactor_width - (2 * FUEL_SIZE), HEIGHT - drop_height - 50, 2, 8, 0, 0, function (x, y) {
let m = make_reflector(x, y);
state.reflectors.push(m);
state.core_materials.push(m);
return m;
});
let reflector_xtra = Matter.Composites.stack((2 * FUEL_SIZE), HEIGHT - drop_height, 1, 10, 0, 0, function (x, y) {
let m = make_reflector(x, y);
state.reflectors.push(m);
state.core_materials.push(m);
return m;
});
// let reflector_top = Matter.Composites.stack(x_pos, HEIGHT - drop_height - 300, 10, 1, 0, 0, function (x, y) {
// let m = make_reflector(x, y);
// reflectors.push(m);
// core_materials.push(m);
// return m;
// });
let reflector_bottom = Matter.Composites.stack(reactor_left_wall, HEIGHT - 40, 10, 1, 0, 0, function (x, y) {
let m = make_reflector(x, y);
state.reflectors.push(m);
state.core_materials.push(m);
return m;
});
let rand_stack = Matter.Composites.stack(reactor_left_wall + FUEL_SIZE * 2, HEIGHT - drop_height + 50, 5, 5, 0, 0, function (x, y) {
let rnd = Math.random();
if (rnd < 0.25) {
let m = make_moderator(x, y);
state.moderators.push(m);
state.core_materials.push(m);
return m;
}
if (rnd < 0.35) {
let m = make_reflector(x, y);
state.reflectors.push(m);
state.core_materials.push(m);
return m;
}
if (rnd < 0.50) {
let m = make_poison(x, y);
state.poisons.push(m);
state.core_materials.push(m);
return m;
}
let f = make_fuel(x, y);
state.fuels.push(f);
return f;
});
Matter.World.add(engine.world, [
poison_stack,
moderator_stack,
reflector_bottom,
reflector_left,
reflector_right,
//reflector_top,
reflector_xtra,
rand_stack,
// boundary walls
wall(WIDTH / 2, 0, WIDTH, WALL_THICKNESS), // top
wall(WIDTH / 2, HEIGHT, WIDTH, WALL_THICKNESS), // bottom
wall(0, HEIGHT / 2, WALL_THICKNESS, HEIGHT), // left edge
wall(reactor_left_wall, HEIGHT, WALL_THICKNESS, HEIGHT), // reactor right
wall(reactor_width + reactor_left_wall, HEIGHT, WALL_THICKNESS, HEIGHT), // reactor left wall
wall(WIDTH, HEIGHT / 2, WALL_THICKNESS, HEIGHT), // right edge
]);
//re add mouse since we deleted everything
Matter.World.add(engine.world, mouseConstraint);
};