-
Notifications
You must be signed in to change notification settings - Fork 2
/
levelGen.js
71 lines (67 loc) · 1.36 KB
/
levelGen.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
import { roomHeight, roomWidth, uiOffset } from "./utils/constants.js";
import { floor } from "./utils/helpers.js";
let level = [];
for (let i = 0; i < roomWidth / 16; i += 1) {
let slice = "";
for (let j = 0; j < roomHeight / 16; j += 1) {
if (
i === 0 ||
j === 0 ||
i === floor(roomWidth / 16) - 1 ||
j === floor(roomHeight / 16) - 1
) {
slice += "w";
continue;
}
slice += " ";
}
level.push(slice);
}
export const generateLevel = () => {
let op = 0;
add([
"wall",
opacity(op),
color(255, 0, 0),
rect(roomWidth, 16),
pos(uiOffset / 2, 8 + uiOffset - 6),
area(),
solid(),
origin("left"),
{ dir: "topdown" },
]);
add([
"wall",
opacity(op),
color(255, 0, 0),
rect(roomWidth, 16),
pos(uiOffset / 2, roomHeight + 8 + uiOffset / 2 - 4),
area(),
solid(),
origin("left"),
{ dir: "topdown" },
]);
add([
"wall",
opacity(op),
color(255, 0, 0),
rect(16, roomHeight),
pos(8 + uiOffset / 2 - 4, 8 + uiOffset / 2),
area(),
solid(),
origin("top"),
{ dir: "leftright" },
]);
add([
"wall",
opacity(op),
color(255, 0, 0),
rect(16, roomHeight),
pos(roomWidth + uiOffset / 2 - 4, 8 + uiOffset / 2),
area(),
solid(),
origin("top"),
{ dir: "leftright" },
]);
};
export const levelMap = level;