-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
249 lines (222 loc) · 11.2 KB
/
index.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
const keypress = require('keypress');
const { levels } = require("./levels");
var xindex = 1;
var yindex = 1;
var level = 1;
var dev = 0;
levels(1, 1, 1)
function hitbox() {
if (level == 1){
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 9 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 1 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 6) {xindex = 1;yindex=1}
}
if (level == 2){
if (xindex == 2 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 9 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 1 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 7) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 7) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 7) {xindex = 1;yindex=1}
}
if (level == 3){
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 9 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 1 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 6) {xindex = 1;yindex=1}
}
if (level == 4) {
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 1 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 9 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 6) {xindex = 1;yindex=1}
}
if (level == 5) {
if (xindex == 1 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 2 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 2) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 4) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 5) {xindex = 1;yindex=1}
if (xindex == 10 && yindex == 6) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 3) {xindex = 1;yindex=1}
if (xindex == 3 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 4 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 5 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 6 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 7 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 8 && yindex == 1) {xindex = 1;yindex=1}
if (xindex == 9 && yindex == 1) {xindex = 1;yindex=1}
}
}
keypress(process.stdin);
process.stdin.on('keypress', (ch, key) => {
if (key && key.ctrl && key.name == 'c') {
process.stdin.pause();
}
if (key.name == 'w' || key.name == 'up') {
yindex = yindex - 1;
if (xindex <= 0){xindex=1}
if (yindex <= 0){yindex=1}
hitbox()
levels(level, xindex, yindex)
if (dev == 1) {console.log(`Coords: \x1b[93mX:${xindex}, Y:${yindex}\x1b[37m`)}
}
if (key.name == 'a' || key.name == 'left') {
xindex = xindex - 1;
if (xindex <= 0){xindex=1}
if (yindex <= 0){yindex=1}
if (level == 3) {if (xindex == 5 && yindex == 3) {xindex = 4;yindex=3}}
if (level == 4) {if (xindex == 2 && yindex == 4) {xindex = 7;yindex=2}}
if (level == 5) {if (xindex == 2 && yindex == 2) {xindex = 6;yindex=4}}
if (level == 5) {if (xindex == 5 && yindex == 2) {xindex = 7;yindex=4}}
if (level == 5) {if (xindex == 5 && yindex == 4) {xindex = 3;yindex=2}}
hitbox()
levels(level, xindex, yindex)
if (dev == 1) {console.log(`Coords: \x1b[93mX:${xindex}, Y:${yindex}\x1b[37m`)}
}
if (key.name == 's' || key.name == 'down') {
yindex = yindex + 1;
if (xindex <= 0){xindex=1}
if (yindex <= 0){yindex=1}
hitbox()
levels(level, xindex, yindex)
if (dev == 1) {console.log(`Coords: \x1b[93mX:${xindex}, Y:${yindex}\x1b[37m`)}
if (level == 1) {if (xindex == 9 && yindex == 6) {level = level + 1;xindex=1;yindex=1;}}
if (level == 2) {if (xindex == 9 && yindex == 7) {level = level + 1;xindex=1;yindex=1;}}
if (level == 3) {if (xindex == 9 && yindex == 6) {level = level + 1;xindex=1;yindex=1;}}
if (level == 4) {if (xindex == 9 && yindex == 6) {level = level + 1;xindex=1;yindex=1;}}
if (level == 5) {if (xindex == 9 && yindex == 6) {level = level + 1;xindex=1;yindex=1;}}
}
if (key.name == 'd' || key.name == 'right') {
xindex = xindex + 1;
if (xindex <= 0){xindex=1}
if (yindex <= 0){yindex=1}
if (level == 3) {if (xindex == 5 && yindex == 3) {xindex = 6;yindex=3}}
if (level == 4) {if (xindex == 8 && yindex == 2) {xindex = 3;yindex=4}}
if (level == 5) {if (xindex == 5 && yindex == 4) {xindex = 4;yindex=2}}
if (level == 5) {if (xindex == 5 && yindex == 2) {xindex = 4;yindex=4}}
if (level == 5) {if (xindex == 8 && yindex == 4) {xindex = 6;yindex=2}}
hitbox()
levels(level, xindex, yindex)
if (dev == 1) {console.log(`Coords: \x1b[93mX:${xindex}, Y:${yindex}\x1b[37m`)}
}
if (key.name == 'e') {
dev = 1
}
});
process.stdin.setRawMode(true);
process.stdin.resume();