terminull-arcade 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-EQAKR7UF.js +5871 -0
- package/dist/chunk-EQAKR7UF.js.map +1 -0
- package/dist/cli.js +47 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +478 -7
- package/dist/index.js +1721 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-WCZVPTEK.js +0 -3294
- package/dist/chunk-WCZVPTEK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,12 +6,15 @@ import {
|
|
|
6
6
|
APP_VERSION,
|
|
7
7
|
AchievementManager,
|
|
8
8
|
ArcadeMenu,
|
|
9
|
-
|
|
9
|
+
Cyber2048Game,
|
|
10
|
+
CyberBreakoutGame,
|
|
11
|
+
CyberDinoGame,
|
|
12
|
+
CyberTowerGame,
|
|
10
13
|
CyberViperGame,
|
|
11
14
|
DeterministicRNG,
|
|
15
|
+
HashMatrixGame,
|
|
12
16
|
MIN_TERMINAL_COLUMNS,
|
|
13
17
|
MIN_TERMINAL_ROWS,
|
|
14
|
-
NeonCircuitGame,
|
|
15
18
|
PacketManGame,
|
|
16
19
|
StorageManager,
|
|
17
20
|
THEMES,
|
|
@@ -20,6 +23,7 @@ import {
|
|
|
20
23
|
TerminullEngine,
|
|
21
24
|
UserProfileSchema,
|
|
22
25
|
UserSettingsSchema,
|
|
26
|
+
VoidInvadersGame,
|
|
23
27
|
checkTerminalDimensions,
|
|
24
28
|
clamp,
|
|
25
29
|
defaultAchievements,
|
|
@@ -28,9 +32,1708 @@ import {
|
|
|
28
32
|
defaultStorage,
|
|
29
33
|
formatTime,
|
|
30
34
|
getTheme,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
padRightVisible,
|
|
36
|
+
playArcadeLoadingScreen,
|
|
37
|
+
playTerminalBell,
|
|
38
|
+
stripAnsi,
|
|
39
|
+
visibleLength,
|
|
40
|
+
wordWrap
|
|
41
|
+
} from "./chunk-EQAKR7UF.js";
|
|
42
|
+
|
|
43
|
+
// src/games/neon-circuit/index.ts
|
|
44
|
+
var NeonCircuitGame = class {
|
|
45
|
+
id = "neon-circuit";
|
|
46
|
+
metadata = ALL_GAMES_METADATA["neon-circuit"];
|
|
47
|
+
config = null;
|
|
48
|
+
renderer = defaultRenderer;
|
|
49
|
+
input = new TerminalInputHandler();
|
|
50
|
+
rng = new DeterministicRNG();
|
|
51
|
+
state = {
|
|
52
|
+
grid: [],
|
|
53
|
+
width: 5,
|
|
54
|
+
height: 5,
|
|
55
|
+
cursorX: 0,
|
|
56
|
+
cursorY: 0,
|
|
57
|
+
movesRemaining: 25,
|
|
58
|
+
maxMoves: 25,
|
|
59
|
+
score: 0,
|
|
60
|
+
level: 1,
|
|
61
|
+
targetsRemaining: 1,
|
|
62
|
+
totalTargets: 1,
|
|
63
|
+
isWon: false,
|
|
64
|
+
isGameOver: false
|
|
65
|
+
};
|
|
66
|
+
isPaused = false;
|
|
67
|
+
pauseMenuIndex = 0;
|
|
68
|
+
showTutorial = true;
|
|
69
|
+
init(config) {
|
|
70
|
+
this.config = config;
|
|
71
|
+
this.renderer.setTheme(config.theme);
|
|
72
|
+
this.rng = new DeterministicRNG(config.seed || Date.now());
|
|
73
|
+
if (config.skipTutorial !== void 0) {
|
|
74
|
+
this.showTutorial = !config.skipTutorial;
|
|
75
|
+
}
|
|
76
|
+
this.setupLevel(1, config.difficulty);
|
|
77
|
+
}
|
|
78
|
+
start() {
|
|
79
|
+
this.isPaused = false;
|
|
80
|
+
this.render();
|
|
81
|
+
this.input.start(
|
|
82
|
+
(key) => this.handleInput(key),
|
|
83
|
+
() => {
|
|
84
|
+
this.destroy();
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
pause() {
|
|
90
|
+
this.isPaused = true;
|
|
91
|
+
}
|
|
92
|
+
resume() {
|
|
93
|
+
this.isPaused = false;
|
|
94
|
+
this.render();
|
|
95
|
+
}
|
|
96
|
+
restart() {
|
|
97
|
+
if (this.config) {
|
|
98
|
+
this.state.score = 0;
|
|
99
|
+
this.setupLevel(1, this.config.difficulty);
|
|
100
|
+
this.render();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
saveState() {
|
|
104
|
+
return {
|
|
105
|
+
state: this.state,
|
|
106
|
+
showTutorial: this.showTutorial
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
loadState(saved) {
|
|
110
|
+
if (saved["state"]) {
|
|
111
|
+
this.state = saved["state"];
|
|
112
|
+
}
|
|
113
|
+
if (saved["showTutorial"] !== void 0) {
|
|
114
|
+
this.showTutorial = !!saved["showTutorial"];
|
|
115
|
+
}
|
|
116
|
+
this.updatePowerFlow();
|
|
117
|
+
}
|
|
118
|
+
destroy() {
|
|
119
|
+
this.input.stop();
|
|
120
|
+
}
|
|
121
|
+
setupLevel(level, difficulty) {
|
|
122
|
+
let size = 5;
|
|
123
|
+
let moves = 20;
|
|
124
|
+
switch (difficulty) {
|
|
125
|
+
case "easy":
|
|
126
|
+
size = 4;
|
|
127
|
+
moves = 25;
|
|
128
|
+
break;
|
|
129
|
+
case "normal":
|
|
130
|
+
size = 5;
|
|
131
|
+
moves = 22;
|
|
132
|
+
break;
|
|
133
|
+
case "hard":
|
|
134
|
+
size = 6;
|
|
135
|
+
moves = 20;
|
|
136
|
+
break;
|
|
137
|
+
case "insane":
|
|
138
|
+
size = 7;
|
|
139
|
+
moves = 18;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
this.state.width = size;
|
|
143
|
+
this.state.height = size;
|
|
144
|
+
this.state.level = level;
|
|
145
|
+
this.state.maxMoves = moves;
|
|
146
|
+
this.state.movesRemaining = moves;
|
|
147
|
+
this.state.cursorX = 0;
|
|
148
|
+
this.state.cursorY = 0;
|
|
149
|
+
this.state.isWon = false;
|
|
150
|
+
this.state.isGameOver = false;
|
|
151
|
+
const grid = [];
|
|
152
|
+
for (let y = 0; y < size; y++) {
|
|
153
|
+
const row = [];
|
|
154
|
+
for (let x = 0; x < size; x++) {
|
|
155
|
+
row.push(this.createRandomTile(x, y, size, difficulty));
|
|
156
|
+
}
|
|
157
|
+
row.push();
|
|
158
|
+
grid.push(row);
|
|
159
|
+
}
|
|
160
|
+
grid[0][0] = {
|
|
161
|
+
type: "source",
|
|
162
|
+
rotation: 0,
|
|
163
|
+
baseConnections: [false, true, true, false],
|
|
164
|
+
currentConnections: [false, true, true, false],
|
|
165
|
+
isPowered: true,
|
|
166
|
+
isFixed: true
|
|
167
|
+
};
|
|
168
|
+
grid[size - 1][size - 1] = {
|
|
169
|
+
type: "target",
|
|
170
|
+
rotation: 0,
|
|
171
|
+
baseConnections: [true, false, false, true],
|
|
172
|
+
currentConnections: [true, false, false, true],
|
|
173
|
+
isPowered: false,
|
|
174
|
+
isFixed: true
|
|
175
|
+
};
|
|
176
|
+
if (difficulty === "insane") {
|
|
177
|
+
grid[0][size - 1] = {
|
|
178
|
+
type: "target",
|
|
179
|
+
rotation: 0,
|
|
180
|
+
baseConnections: [false, false, true, true],
|
|
181
|
+
currentConnections: [false, false, true, true],
|
|
182
|
+
isPowered: false,
|
|
183
|
+
isFixed: true
|
|
184
|
+
};
|
|
185
|
+
this.state.totalTargets = 2;
|
|
186
|
+
this.state.targetsRemaining = 2;
|
|
187
|
+
} else {
|
|
188
|
+
this.state.totalTargets = 1;
|
|
189
|
+
this.state.targetsRemaining = 1;
|
|
190
|
+
}
|
|
191
|
+
this.state.grid = grid;
|
|
192
|
+
this.updatePowerFlow();
|
|
193
|
+
}
|
|
194
|
+
createRandomTile(x, y, size, difficulty) {
|
|
195
|
+
if ((difficulty === "hard" || difficulty === "insane") && this.rng.next() < 0.12 && (x > 0 || y > 0)) {
|
|
196
|
+
return {
|
|
197
|
+
type: "blocked",
|
|
198
|
+
rotation: 0,
|
|
199
|
+
baseConnections: [false, false, false, false],
|
|
200
|
+
currentConnections: [false, false, false, false],
|
|
201
|
+
isPowered: false,
|
|
202
|
+
isFixed: true
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const roll = this.rng.next();
|
|
206
|
+
let type = "corner";
|
|
207
|
+
let base = [true, true, false, false];
|
|
208
|
+
if (roll < 0.4) {
|
|
209
|
+
type = "straight";
|
|
210
|
+
base = [true, false, true, false];
|
|
211
|
+
} else if (roll < 0.75) {
|
|
212
|
+
type = "corner";
|
|
213
|
+
base = [true, true, false, false];
|
|
214
|
+
} else if (roll < 0.92) {
|
|
215
|
+
type = "t-shape";
|
|
216
|
+
base = [true, true, false, true];
|
|
217
|
+
} else {
|
|
218
|
+
type = "cross";
|
|
219
|
+
base = [true, true, true, true];
|
|
220
|
+
}
|
|
221
|
+
const rotation = this.rng.nextInt(0, 3);
|
|
222
|
+
const current = this.rotateMask(base, rotation);
|
|
223
|
+
return {
|
|
224
|
+
type,
|
|
225
|
+
rotation,
|
|
226
|
+
baseConnections: base,
|
|
227
|
+
currentConnections: current,
|
|
228
|
+
isPowered: false,
|
|
229
|
+
isFixed: false
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
rotateMask(mask, times) {
|
|
233
|
+
const res = [...mask];
|
|
234
|
+
for (let i = 0; i < times % 4; i++) {
|
|
235
|
+
const [top, right, bottom, left] = res;
|
|
236
|
+
res[0] = left;
|
|
237
|
+
res[1] = top;
|
|
238
|
+
res[2] = right;
|
|
239
|
+
res[3] = bottom;
|
|
240
|
+
}
|
|
241
|
+
return res;
|
|
242
|
+
}
|
|
243
|
+
rotateTileAt(x, y) {
|
|
244
|
+
const tile = this.state.grid[y]?.[x];
|
|
245
|
+
if (!tile || tile.isFixed || this.state.isWon || this.state.isGameOver) return false;
|
|
246
|
+
tile.rotation = (tile.rotation + 1) % 4;
|
|
247
|
+
tile.currentConnections = this.rotateMask(tile.baseConnections, tile.rotation);
|
|
248
|
+
this.state.movesRemaining--;
|
|
249
|
+
this.updatePowerFlow();
|
|
250
|
+
if (this.config?.soundEnabled) {
|
|
251
|
+
playTerminalBell();
|
|
252
|
+
}
|
|
253
|
+
if (this.state.isWon) {
|
|
254
|
+
const bonus = this.state.movesRemaining * 100;
|
|
255
|
+
this.state.score += 500 + bonus;
|
|
256
|
+
this.config?.onScoreUpdate?.(this.state.score);
|
|
257
|
+
this.config?.onAchievementUnlock?.("first_spark");
|
|
258
|
+
if (this.state.movesRemaining >= 5) {
|
|
259
|
+
this.config?.onAchievementUnlock?.("overclocked");
|
|
260
|
+
}
|
|
261
|
+
if (this.config?.difficulty === "insane") {
|
|
262
|
+
this.config?.onAchievementUnlock?.("grid_master");
|
|
263
|
+
}
|
|
264
|
+
} else if (this.state.movesRemaining <= 0) {
|
|
265
|
+
this.state.isGameOver = true;
|
|
266
|
+
this.config?.onGameOver?.(this.state.score);
|
|
267
|
+
}
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
updatePowerFlow() {
|
|
271
|
+
const { width, height, grid } = this.state;
|
|
272
|
+
for (let y = 0; y < height; y++) {
|
|
273
|
+
for (let x = 0; x < width; x++) {
|
|
274
|
+
if (grid[y][x].type !== "source") {
|
|
275
|
+
grid[y][x].isPowered = false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const queue = [[0, 0]];
|
|
280
|
+
const visited = /* @__PURE__ */ new Set();
|
|
281
|
+
visited.add("0,0");
|
|
282
|
+
let targetsLit = 0;
|
|
283
|
+
const dx = [0, 1, 0, -1];
|
|
284
|
+
const dy = [-1, 0, 1, 0];
|
|
285
|
+
const oppositeDir = [2, 3, 0, 1];
|
|
286
|
+
while (queue.length > 0) {
|
|
287
|
+
const [cx, cy] = queue.shift();
|
|
288
|
+
const curr = grid[cy][cx];
|
|
289
|
+
for (let dir = 0; dir < 4; dir++) {
|
|
290
|
+
if (!curr.currentConnections[dir]) continue;
|
|
291
|
+
const nx = cx + dx[dir];
|
|
292
|
+
const ny = cy + dy[dir];
|
|
293
|
+
if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue;
|
|
294
|
+
const key = `${nx},${ny}`;
|
|
295
|
+
if (visited.has(key)) continue;
|
|
296
|
+
const neighbor = grid[ny][nx];
|
|
297
|
+
if (neighbor.type === "blocked") continue;
|
|
298
|
+
const opp = oppositeDir[dir];
|
|
299
|
+
if (neighbor.currentConnections[opp]) {
|
|
300
|
+
neighbor.isPowered = true;
|
|
301
|
+
visited.add(key);
|
|
302
|
+
queue.push([nx, ny]);
|
|
303
|
+
if (neighbor.type === "target") {
|
|
304
|
+
targetsLit++;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
this.state.targetsRemaining = this.state.totalTargets - targetsLit;
|
|
310
|
+
if (this.state.targetsRemaining === 0) {
|
|
311
|
+
this.state.isWon = true;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
handleInput(key) {
|
|
315
|
+
if (this.showTutorial) {
|
|
316
|
+
if (key.name === "return" || key.name === "space") {
|
|
317
|
+
this.showTutorial = false;
|
|
318
|
+
this.render();
|
|
319
|
+
} else if (key.name === "escape" || key.name === "q") {
|
|
320
|
+
this.destroy();
|
|
321
|
+
this.config?.onExit?.();
|
|
322
|
+
}
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (this.isPaused) {
|
|
326
|
+
if (key.name === "up" || key.name === "w") {
|
|
327
|
+
this.pauseMenuIndex = (this.pauseMenuIndex - 1 + 3) % 3;
|
|
328
|
+
this.render();
|
|
329
|
+
} else if (key.name === "down" || key.name === "s") {
|
|
330
|
+
this.pauseMenuIndex = (this.pauseMenuIndex + 1) % 3;
|
|
331
|
+
this.render();
|
|
332
|
+
} else if (key.name === "return" || key.name === "space") {
|
|
333
|
+
if (this.pauseMenuIndex === 0) {
|
|
334
|
+
this.isPaused = false;
|
|
335
|
+
this.render();
|
|
336
|
+
} else if (this.pauseMenuIndex === 1) {
|
|
337
|
+
this.isPaused = false;
|
|
338
|
+
this.setupLevel(this.state.level, this.config?.difficulty || "normal");
|
|
339
|
+
this.render();
|
|
340
|
+
} else if (this.pauseMenuIndex === 2) {
|
|
341
|
+
this.destroy();
|
|
342
|
+
this.config?.onExit?.();
|
|
343
|
+
}
|
|
344
|
+
} else if (key.name === "escape" || key.name === "p") {
|
|
345
|
+
this.isPaused = false;
|
|
346
|
+
this.render();
|
|
347
|
+
} else if (key.name === "q") {
|
|
348
|
+
this.destroy();
|
|
349
|
+
this.config?.onExit?.();
|
|
350
|
+
}
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (key.name === "escape" || key.name === "p") {
|
|
354
|
+
this.isPaused = true;
|
|
355
|
+
this.pauseMenuIndex = 0;
|
|
356
|
+
this.render();
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (key.name === "q") {
|
|
360
|
+
this.destroy();
|
|
361
|
+
this.config?.onExit?.();
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (this.state.isWon) {
|
|
365
|
+
if (key.name === "return" || key.name === "space") {
|
|
366
|
+
this.setupLevel(this.state.level + 1, this.config?.difficulty || "normal");
|
|
367
|
+
this.render();
|
|
368
|
+
} else if (key.name === "escape" || key.name === "q") {
|
|
369
|
+
this.destroy();
|
|
370
|
+
this.config?.onExit?.();
|
|
371
|
+
}
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (this.state.isGameOver) {
|
|
375
|
+
if (key.name === "r") {
|
|
376
|
+
this.restart();
|
|
377
|
+
} else if (key.name === "escape" || key.name === "q") {
|
|
378
|
+
this.destroy();
|
|
379
|
+
this.config?.onExit?.();
|
|
380
|
+
}
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (key.name === "up" || key.name === "w") {
|
|
384
|
+
this.state.cursorY = Math.max(0, this.state.cursorY - 1);
|
|
385
|
+
this.render();
|
|
386
|
+
} else if (key.name === "down" || key.name === "s") {
|
|
387
|
+
this.state.cursorY = Math.min(this.state.height - 1, this.state.cursorY + 1);
|
|
388
|
+
this.render();
|
|
389
|
+
} else if (key.name === "left" || key.name === "a") {
|
|
390
|
+
this.state.cursorX = Math.max(0, this.state.cursorX - 1);
|
|
391
|
+
this.render();
|
|
392
|
+
} else if (key.name === "right" || key.name === "d") {
|
|
393
|
+
this.state.cursorX = Math.min(this.state.width - 1, this.state.cursorX + 1);
|
|
394
|
+
this.render();
|
|
395
|
+
} else if (key.name === "space" || key.name === "return") {
|
|
396
|
+
this.rotateTileAt(this.state.cursorX, this.state.cursorY);
|
|
397
|
+
this.render();
|
|
398
|
+
} else if (key.name === "r") {
|
|
399
|
+
this.setupLevel(this.state.level, this.config?.difficulty || "normal");
|
|
400
|
+
this.render();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
render() {
|
|
404
|
+
const t = this.renderer.getTheme();
|
|
405
|
+
if (this.showTutorial) {
|
|
406
|
+
const tutorialLines = [
|
|
407
|
+
"",
|
|
408
|
+
t.highlight("OBJECTIVE: ROUTE HIGH-VOLTAGE FLUX"),
|
|
409
|
+
"",
|
|
410
|
+
"\u2022 Navigate cursor using Arrow Keys or WASD.",
|
|
411
|
+
"\u2022 Press Space or Enter to rotate circuit tiles clockwise.",
|
|
412
|
+
"\u2022 Connect the glowing [S] Power Source to the [T] Target nodes.",
|
|
413
|
+
"\u2022 Watch your Capacity (Moves Remaining) meter.",
|
|
414
|
+
"\u2022 Obstacles [\u2593] cannot conduct energy or rotate.",
|
|
415
|
+
"",
|
|
416
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
417
|
+
t.primary("Press Space or Enter to start \u2502 Esc / Q to Exit")
|
|
418
|
+
];
|
|
419
|
+
const box = this.renderer.createBox(tutorialLines, 64, "CIRCUIT PROTOCOL MANUAL");
|
|
420
|
+
this.renderer.clear();
|
|
421
|
+
this.renderer.draw(`
|
|
422
|
+
|
|
423
|
+
${box}
|
|
424
|
+
`);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (this.isPaused) {
|
|
428
|
+
const pauseItems = ["Resume Circuit (Esc / Enter)", "Restart Level (R)", "Quit to Arcade / Terminal (Q)"];
|
|
429
|
+
const pauseLines = [
|
|
430
|
+
"",
|
|
431
|
+
t.highlight("\u2550\u2550\u2550 CIRCUIT SUBROUTINE PAUSED \u2550\u2550\u2550"),
|
|
432
|
+
"",
|
|
433
|
+
...pauseItems.map((item, idx) => {
|
|
434
|
+
if (idx === this.pauseMenuIndex) {
|
|
435
|
+
return t.primary(` \u25B6 ${t.highlight(item)}`);
|
|
436
|
+
}
|
|
437
|
+
return t.muted(` ${item}`);
|
|
438
|
+
}),
|
|
439
|
+
"",
|
|
440
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
441
|
+
t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Quit")
|
|
442
|
+
];
|
|
443
|
+
const pauseBox = this.renderer.createBox(pauseLines, 64, "SYSTEM PAUSE");
|
|
444
|
+
this.renderer.clear();
|
|
445
|
+
this.renderer.draw(`
|
|
446
|
+
|
|
447
|
+
${pauseBox}
|
|
448
|
+
`);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const header = this.renderer.renderHeader({
|
|
452
|
+
title: "NEON CIRCUIT",
|
|
453
|
+
category: "PUZZLE",
|
|
454
|
+
difficulty: this.config?.difficulty,
|
|
455
|
+
score: this.state.score,
|
|
456
|
+
level: this.state.level
|
|
457
|
+
});
|
|
458
|
+
const lines = [];
|
|
459
|
+
const { width, height, grid, cursorX, cursorY } = this.state;
|
|
460
|
+
lines.push(` Level: ${t.primary(this.state.level.toString())} Moves: ${this.state.movesRemaining > 5 ? t.success(this.state.movesRemaining.toString()) : t.error(this.state.movesRemaining.toString())} Targets: ${t.accent(`${this.state.totalTargets - this.state.targetsRemaining}/${this.state.totalTargets}`)}`);
|
|
461
|
+
lines.push("");
|
|
462
|
+
for (let y = 0; y < height; y++) {
|
|
463
|
+
let rowStr = " ";
|
|
464
|
+
for (let x = 0; x < width; x++) {
|
|
465
|
+
const tile = grid[y][x];
|
|
466
|
+
const isCursor = x === cursorX && y === cursorY;
|
|
467
|
+
const glyph = this.getTileGlyph(tile);
|
|
468
|
+
let formatted = glyph;
|
|
469
|
+
if (tile.isPowered) {
|
|
470
|
+
formatted = t.highlight(glyph);
|
|
471
|
+
} else {
|
|
472
|
+
formatted = t.muted(glyph);
|
|
473
|
+
}
|
|
474
|
+
if (isCursor) {
|
|
475
|
+
rowStr += `[${t.accent(glyph)}] `;
|
|
476
|
+
} else {
|
|
477
|
+
rowStr += ` ${formatted} `;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
lines.push(rowStr);
|
|
481
|
+
lines.push("");
|
|
482
|
+
}
|
|
483
|
+
if (this.state.isWon) {
|
|
484
|
+
lines.push(` ${t.success("\u26A1 CIRCUIT SYNCHRONIZED! ALL NODES POWERED!")}`);
|
|
485
|
+
lines.push(` ${t.primary("Press Space or Enter for Next Level...")}`);
|
|
486
|
+
} else if (this.state.isGameOver) {
|
|
487
|
+
lines.push(` ${t.error("\u274C CAPACITY EXHAUSTED! POWER COLLAPSE.")}`);
|
|
488
|
+
lines.push(` ${t.muted("Press R to Retry Level, or P for Pause Menu.")}`);
|
|
489
|
+
} else {
|
|
490
|
+
lines.push(` ${t.muted("Controls: Arrows/WASD: Move \u2502 Space: Rotate \u2502 Esc/P: Pause \u2502 Q: Quit")}`);
|
|
491
|
+
}
|
|
492
|
+
this.renderer.clear();
|
|
493
|
+
this.renderer.draw(`
|
|
494
|
+
${header}
|
|
495
|
+
${lines.join("\n")}
|
|
496
|
+
`);
|
|
497
|
+
}
|
|
498
|
+
getTileGlyph(tile) {
|
|
499
|
+
if (tile.type === "source") return "S";
|
|
500
|
+
if (tile.type === "target") return "T";
|
|
501
|
+
if (tile.type === "blocked") return "\u2593";
|
|
502
|
+
const [top, right, bottom, left] = tile.currentConnections;
|
|
503
|
+
if (top && bottom && !right && !left) return "\u2502";
|
|
504
|
+
if (!top && !bottom && right && left) return "\u2500";
|
|
505
|
+
if (bottom && right && !top && !left) return "\u250C";
|
|
506
|
+
if (bottom && left && !top && !right) return "\u2510";
|
|
507
|
+
if (top && right && !bottom && !left) return "\u2514";
|
|
508
|
+
if (top && left && !bottom && !right) return "\u2518";
|
|
509
|
+
if (top && bottom && right && !left) return "\u251C";
|
|
510
|
+
if (top && bottom && !right && left) return "\u2524";
|
|
511
|
+
if (!top && bottom && right && left) return "\u252C";
|
|
512
|
+
if (top && !bottom && right && left) return "\u2534";
|
|
513
|
+
if (top && bottom && right && left) return "\u253C";
|
|
514
|
+
return "\u2022";
|
|
515
|
+
}
|
|
516
|
+
getState() {
|
|
517
|
+
return this.state;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
// src/games/byte-runner/index.ts
|
|
522
|
+
var HIGHWAY_HEIGHT = 16;
|
|
523
|
+
var LANE_COUNT = 3;
|
|
524
|
+
var ByteRunnerGame = class {
|
|
525
|
+
id = "byte-runner";
|
|
526
|
+
metadata = ALL_GAMES_METADATA["byte-runner"];
|
|
527
|
+
config = null;
|
|
528
|
+
renderer = defaultRenderer;
|
|
529
|
+
input = new TerminalInputHandler();
|
|
530
|
+
rng = new DeterministicRNG();
|
|
531
|
+
gameLoopTimer = null;
|
|
532
|
+
entityIdCounter = 0;
|
|
533
|
+
entities = [];
|
|
534
|
+
state = {
|
|
535
|
+
playerLane: 1,
|
|
536
|
+
isJumping: false,
|
|
537
|
+
jumpTicksRemaining: 0,
|
|
538
|
+
score: 0,
|
|
539
|
+
distance: 0,
|
|
540
|
+
cleanBytesCollected: 0,
|
|
541
|
+
activeShield: false,
|
|
542
|
+
slowMotionTicks: 0,
|
|
543
|
+
magnetTicks: 0,
|
|
544
|
+
doubleScoreTicks: 0,
|
|
545
|
+
speedMs: 110,
|
|
546
|
+
isGameOver: false,
|
|
547
|
+
multiplier: 1
|
|
548
|
+
};
|
|
549
|
+
isPaused = false;
|
|
550
|
+
pauseMenuIndex = 0;
|
|
551
|
+
showTutorial = true;
|
|
552
|
+
init(config) {
|
|
553
|
+
this.config = config;
|
|
554
|
+
this.renderer.setTheme(config.theme);
|
|
555
|
+
this.rng = new DeterministicRNG(config.seed || Date.now());
|
|
556
|
+
if (config.skipTutorial !== void 0) {
|
|
557
|
+
this.showTutorial = !config.skipTutorial;
|
|
558
|
+
}
|
|
559
|
+
this.resetState(config.difficulty);
|
|
560
|
+
}
|
|
561
|
+
start() {
|
|
562
|
+
this.isPaused = false;
|
|
563
|
+
this.render();
|
|
564
|
+
this.input.start(
|
|
565
|
+
(key) => this.handleInput(key),
|
|
566
|
+
() => {
|
|
567
|
+
this.destroy();
|
|
568
|
+
process.exit(0);
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
this.scheduleNextTick();
|
|
572
|
+
}
|
|
573
|
+
pause() {
|
|
574
|
+
this.isPaused = true;
|
|
575
|
+
if (this.gameLoopTimer) {
|
|
576
|
+
clearTimeout(this.gameLoopTimer);
|
|
577
|
+
this.gameLoopTimer = null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
resume() {
|
|
581
|
+
this.isPaused = false;
|
|
582
|
+
this.scheduleNextTick();
|
|
583
|
+
this.render();
|
|
584
|
+
}
|
|
585
|
+
restart() {
|
|
586
|
+
if (this.config) {
|
|
587
|
+
this.resetState(this.config.difficulty);
|
|
588
|
+
this.scheduleNextTick();
|
|
589
|
+
this.render();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
saveState() {
|
|
593
|
+
return {
|
|
594
|
+
state: this.state,
|
|
595
|
+
entities: this.entities,
|
|
596
|
+
showTutorial: this.showTutorial
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
loadState(saved) {
|
|
600
|
+
if (saved["state"]) {
|
|
601
|
+
this.state = saved["state"];
|
|
602
|
+
}
|
|
603
|
+
if (saved["entities"]) {
|
|
604
|
+
this.entities = saved["entities"];
|
|
605
|
+
}
|
|
606
|
+
if (saved["showTutorial"] !== void 0) {
|
|
607
|
+
this.showTutorial = !!saved["showTutorial"];
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
destroy() {
|
|
611
|
+
if (this.gameLoopTimer) {
|
|
612
|
+
clearTimeout(this.gameLoopTimer);
|
|
613
|
+
this.gameLoopTimer = null;
|
|
614
|
+
}
|
|
615
|
+
this.input.stop();
|
|
616
|
+
}
|
|
617
|
+
resetState(difficulty) {
|
|
618
|
+
let baseSpeed = 110;
|
|
619
|
+
switch (difficulty) {
|
|
620
|
+
case "easy":
|
|
621
|
+
baseSpeed = 140;
|
|
622
|
+
break;
|
|
623
|
+
case "normal":
|
|
624
|
+
baseSpeed = 110;
|
|
625
|
+
break;
|
|
626
|
+
case "hard":
|
|
627
|
+
baseSpeed = 85;
|
|
628
|
+
break;
|
|
629
|
+
case "insane":
|
|
630
|
+
baseSpeed = 65;
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
this.state = {
|
|
634
|
+
playerLane: 1,
|
|
635
|
+
isJumping: false,
|
|
636
|
+
jumpTicksRemaining: 0,
|
|
637
|
+
score: 0,
|
|
638
|
+
distance: 0,
|
|
639
|
+
cleanBytesCollected: 0,
|
|
640
|
+
activeShield: false,
|
|
641
|
+
slowMotionTicks: 0,
|
|
642
|
+
magnetTicks: 0,
|
|
643
|
+
doubleScoreTicks: 0,
|
|
644
|
+
speedMs: baseSpeed,
|
|
645
|
+
isGameOver: false,
|
|
646
|
+
multiplier: 1
|
|
647
|
+
};
|
|
648
|
+
this.entities = [];
|
|
649
|
+
}
|
|
650
|
+
scheduleNextTick() {
|
|
651
|
+
if (this.gameLoopTimer) {
|
|
652
|
+
clearTimeout(this.gameLoopTimer);
|
|
653
|
+
}
|
|
654
|
+
if (this.isPaused || this.state.isGameOver || this.showTutorial) return;
|
|
655
|
+
let delay = this.state.speedMs;
|
|
656
|
+
if (this.state.slowMotionTicks > 0) {
|
|
657
|
+
delay = Math.round(delay * 1.6);
|
|
658
|
+
}
|
|
659
|
+
this.gameLoopTimer = setTimeout(() => {
|
|
660
|
+
this.tick();
|
|
661
|
+
this.scheduleNextTick();
|
|
662
|
+
}, delay);
|
|
663
|
+
}
|
|
664
|
+
tick() {
|
|
665
|
+
if (this.state.isGameOver || this.isPaused || this.showTutorial) return;
|
|
666
|
+
this.state.distance += 1;
|
|
667
|
+
const pointGain = 1 * (this.state.doubleScoreTicks > 0 ? 2 : 1);
|
|
668
|
+
this.state.score += pointGain;
|
|
669
|
+
if (this.state.jumpTicksRemaining > 0) {
|
|
670
|
+
this.state.jumpTicksRemaining--;
|
|
671
|
+
if (this.state.jumpTicksRemaining === 0) {
|
|
672
|
+
this.state.isJumping = false;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (this.state.slowMotionTicks > 0) this.state.slowMotionTicks--;
|
|
676
|
+
if (this.state.magnetTicks > 0) this.state.magnetTicks--;
|
|
677
|
+
if (this.state.doubleScoreTicks > 0) this.state.doubleScoreTicks--;
|
|
678
|
+
for (const ent of this.entities) {
|
|
679
|
+
ent.y += 1;
|
|
680
|
+
if (this.state.magnetTicks > 0 && ent.type === "clean" && ent.y >= HIGHWAY_HEIGHT - 6) {
|
|
681
|
+
ent.lane = this.state.playerLane;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const playerY = HIGHWAY_HEIGHT - 2;
|
|
685
|
+
const remainingEntities = [];
|
|
686
|
+
for (const ent of this.entities) {
|
|
687
|
+
if (ent.y === playerY && ent.lane === this.state.playerLane) {
|
|
688
|
+
if (ent.type === "corrupt") {
|
|
689
|
+
if (this.state.isJumping) {
|
|
690
|
+
remainingEntities.push(ent);
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (this.state.activeShield) {
|
|
694
|
+
this.state.activeShield = false;
|
|
695
|
+
this.config?.onAchievementUnlock?.("shield_matrix");
|
|
696
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
this.state.isGameOver = true;
|
|
700
|
+
this.config?.onGameOver?.(this.state.score);
|
|
701
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
702
|
+
break;
|
|
703
|
+
} else if (ent.type === "clean") {
|
|
704
|
+
this.state.cleanBytesCollected++;
|
|
705
|
+
this.state.score += 100 * (this.state.doubleScoreTicks > 0 ? 2 : 1);
|
|
706
|
+
this.config?.onScoreUpdate?.(this.state.score);
|
|
707
|
+
if (this.state.cleanBytesCollected >= 50) {
|
|
708
|
+
this.config?.onAchievementUnlock?.("packet_chaser");
|
|
709
|
+
}
|
|
710
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
711
|
+
continue;
|
|
712
|
+
} else if (ent.type === "powerup") {
|
|
713
|
+
this.activatePowerUp(ent.subType);
|
|
714
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (ent.y < HIGHWAY_HEIGHT) {
|
|
719
|
+
remainingEntities.push(ent);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
this.entities = remainingEntities;
|
|
723
|
+
if (this.state.distance >= 5e3) {
|
|
724
|
+
this.config?.onAchievementUnlock?.("hyperspeed");
|
|
725
|
+
}
|
|
726
|
+
if (this.state.distance % 2 === 0) {
|
|
727
|
+
this.spawnHighwayWave();
|
|
728
|
+
}
|
|
729
|
+
if (this.state.distance % 200 === 0 && this.state.speedMs > 45) {
|
|
730
|
+
this.state.speedMs -= 2;
|
|
731
|
+
}
|
|
732
|
+
this.render();
|
|
733
|
+
}
|
|
734
|
+
activatePowerUp(type) {
|
|
735
|
+
switch (type) {
|
|
736
|
+
case "shield":
|
|
737
|
+
this.state.activeShield = true;
|
|
738
|
+
break;
|
|
739
|
+
case "slow":
|
|
740
|
+
this.state.slowMotionTicks = 60;
|
|
741
|
+
break;
|
|
742
|
+
case "magnet":
|
|
743
|
+
this.state.magnetTicks = 70;
|
|
744
|
+
break;
|
|
745
|
+
case "double":
|
|
746
|
+
this.state.doubleScoreTicks = 80;
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
spawnHighwayWave() {
|
|
751
|
+
const roll = this.rng.next();
|
|
752
|
+
const lane = this.rng.nextInt(0, LANE_COUNT - 1);
|
|
753
|
+
if (roll < 0.45) {
|
|
754
|
+
const labels = ["[CORRUPT]", "[BAD_MEM]", "[NULL_PTR]", "[SEG_FLT]"];
|
|
755
|
+
this.entities.push({
|
|
756
|
+
id: ++this.entityIdCounter,
|
|
757
|
+
lane,
|
|
758
|
+
y: 0,
|
|
759
|
+
type: "corrupt",
|
|
760
|
+
label: this.rng.pick(labels)
|
|
761
|
+
});
|
|
762
|
+
} else if (roll < 0.8) {
|
|
763
|
+
const labels = ["0x7F", "0xFF", "[CLEAN]", "[PACKET]"];
|
|
764
|
+
this.entities.push({
|
|
765
|
+
id: ++this.entityIdCounter,
|
|
766
|
+
lane,
|
|
767
|
+
y: 0,
|
|
768
|
+
type: "clean",
|
|
769
|
+
label: this.rng.pick(labels)
|
|
770
|
+
});
|
|
771
|
+
} else if (roll < 0.95) {
|
|
772
|
+
const powerups = ["shield", "slow", "magnet", "double"];
|
|
773
|
+
const chosen = this.rng.pick(powerups);
|
|
774
|
+
const labels = {
|
|
775
|
+
shield: "\u{1F6E1}\uFE0F [SHLD]",
|
|
776
|
+
slow: "\u23F1\uFE0F [SLOW]",
|
|
777
|
+
magnet: "\u{1F9F2} [MAG]",
|
|
778
|
+
double: "\u26A1 [2X]"
|
|
779
|
+
};
|
|
780
|
+
this.entities.push({
|
|
781
|
+
id: ++this.entityIdCounter,
|
|
782
|
+
lane,
|
|
783
|
+
y: 0,
|
|
784
|
+
type: "powerup",
|
|
785
|
+
subType: chosen,
|
|
786
|
+
label: labels[chosen]
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
handleInput(key) {
|
|
791
|
+
if (this.showTutorial) {
|
|
792
|
+
if (key.name === "return" || key.name === "space") {
|
|
793
|
+
this.showTutorial = false;
|
|
794
|
+
this.scheduleNextTick();
|
|
795
|
+
this.render();
|
|
796
|
+
} else if (key.name === "escape" || key.name === "q") {
|
|
797
|
+
this.destroy();
|
|
798
|
+
this.config?.onExit?.();
|
|
799
|
+
}
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (this.isPaused) {
|
|
803
|
+
if (key.name === "up" || key.name === "w") {
|
|
804
|
+
this.pauseMenuIndex = (this.pauseMenuIndex - 1 + 3) % 3;
|
|
805
|
+
this.render();
|
|
806
|
+
} else if (key.name === "down" || key.name === "s") {
|
|
807
|
+
this.pauseMenuIndex = (this.pauseMenuIndex + 1) % 3;
|
|
808
|
+
this.render();
|
|
809
|
+
} else if (key.name === "return" || key.name === "space") {
|
|
810
|
+
if (this.pauseMenuIndex === 0) {
|
|
811
|
+
this.isPaused = false;
|
|
812
|
+
this.scheduleNextTick();
|
|
813
|
+
this.render();
|
|
814
|
+
} else if (this.pauseMenuIndex === 1) {
|
|
815
|
+
this.isPaused = false;
|
|
816
|
+
this.restart();
|
|
817
|
+
} else if (this.pauseMenuIndex === 2) {
|
|
818
|
+
this.destroy();
|
|
819
|
+
this.config?.onExit?.();
|
|
820
|
+
}
|
|
821
|
+
} else if (key.name === "escape" || key.name === "p") {
|
|
822
|
+
this.isPaused = false;
|
|
823
|
+
this.scheduleNextTick();
|
|
824
|
+
this.render();
|
|
825
|
+
} else if (key.name === "q") {
|
|
826
|
+
this.destroy();
|
|
827
|
+
this.config?.onExit?.();
|
|
828
|
+
}
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
if (key.name === "escape" || key.name === "p") {
|
|
832
|
+
this.isPaused = true;
|
|
833
|
+
this.pauseMenuIndex = 0;
|
|
834
|
+
if (this.gameLoopTimer) {
|
|
835
|
+
clearTimeout(this.gameLoopTimer);
|
|
836
|
+
this.gameLoopTimer = null;
|
|
837
|
+
}
|
|
838
|
+
this.render();
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
if (key.name === "q") {
|
|
842
|
+
this.destroy();
|
|
843
|
+
this.config?.onExit?.();
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (this.state.isGameOver) {
|
|
847
|
+
if (key.name === "r") {
|
|
848
|
+
this.restart();
|
|
849
|
+
} else if (key.name === "escape" || key.name === "q") {
|
|
850
|
+
this.destroy();
|
|
851
|
+
this.config?.onExit?.();
|
|
852
|
+
}
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
if (key.name === "left" || key.name === "a") {
|
|
856
|
+
if (this.state.playerLane > 0) {
|
|
857
|
+
this.state.playerLane--;
|
|
858
|
+
this.render();
|
|
859
|
+
}
|
|
860
|
+
} else if (key.name === "right" || key.name === "d") {
|
|
861
|
+
if (this.state.playerLane < LANE_COUNT - 1) {
|
|
862
|
+
this.state.playerLane++;
|
|
863
|
+
this.render();
|
|
864
|
+
}
|
|
865
|
+
} else if (key.name === "up" || key.name === "w" || key.name === "space") {
|
|
866
|
+
if (!this.state.isJumping) {
|
|
867
|
+
this.state.isJumping = true;
|
|
868
|
+
this.state.jumpTicksRemaining = 3;
|
|
869
|
+
this.render();
|
|
870
|
+
}
|
|
871
|
+
} else if (key.name === "down" || key.name === "s") {
|
|
872
|
+
this.state.isJumping = false;
|
|
873
|
+
this.state.jumpTicksRemaining = 0;
|
|
874
|
+
this.render();
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
render() {
|
|
878
|
+
const t = this.renderer.getTheme();
|
|
879
|
+
if (this.showTutorial) {
|
|
880
|
+
const lines = [
|
|
881
|
+
"",
|
|
882
|
+
t.highlight("OBJECTIVE: SPRINT THE FIBER HIGHWAY"),
|
|
883
|
+
"",
|
|
884
|
+
"\u2022 Use Left/Right (or A/D) to switch between 3 data lanes.",
|
|
885
|
+
"\u2022 Press Up / Space to Phase Jump over low corrupted blocks.",
|
|
886
|
+
"\u2022 Collect Clean Byte packets to boost your score.",
|
|
887
|
+
"\u2022 Grab Power-ups: [SHLD] Shield, [SLOW] Buffer, [MAG] Magnet, [2X] Double.",
|
|
888
|
+
"\u2022 Speed escalates continuously with distance.",
|
|
889
|
+
"",
|
|
890
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
891
|
+
t.primary("Press Space or Enter to launch \u2502 Esc / Q to Exit")
|
|
892
|
+
];
|
|
893
|
+
const box = this.renderer.createBox(lines, 64, "BYTE RUNNER MANUAL");
|
|
894
|
+
this.renderer.clear();
|
|
895
|
+
this.renderer.draw(`
|
|
896
|
+
|
|
897
|
+
${box}
|
|
898
|
+
`);
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
if (this.isPaused) {
|
|
902
|
+
const pauseItems = ["Resume Runner (Esc / Enter)", "Restart Run (R)", "Quit to Arcade / Terminal (Q)"];
|
|
903
|
+
const pauseLines = [
|
|
904
|
+
"",
|
|
905
|
+
t.highlight("\u2550\u2550\u2550 HIGHWAY PACKET STREAM PAUSED \u2550\u2550\u2550"),
|
|
906
|
+
"",
|
|
907
|
+
...pauseItems.map((item, idx) => {
|
|
908
|
+
if (idx === this.pauseMenuIndex) {
|
|
909
|
+
return t.primary(` \u25B6 ${t.highlight(item)}`);
|
|
910
|
+
}
|
|
911
|
+
return t.muted(` ${item}`);
|
|
912
|
+
}),
|
|
913
|
+
"",
|
|
914
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
915
|
+
t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Quit")
|
|
916
|
+
];
|
|
917
|
+
const pauseBox = this.renderer.createBox(pauseLines, 64, "SYSTEM PAUSE");
|
|
918
|
+
this.renderer.clear();
|
|
919
|
+
this.renderer.draw(`
|
|
920
|
+
|
|
921
|
+
${pauseBox}
|
|
922
|
+
`);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
const header = this.renderer.renderHeader({
|
|
926
|
+
title: "BYTE RUNNER",
|
|
927
|
+
category: "ARCADE",
|
|
928
|
+
difficulty: this.config?.difficulty,
|
|
929
|
+
score: this.state.score
|
|
930
|
+
});
|
|
931
|
+
const hudLines = [];
|
|
932
|
+
const distStr = `${t.muted("Distance:")} ${t.primary(`${this.state.distance}m`)}`;
|
|
933
|
+
const bytesStr = `${t.muted("Clean Bytes:")} ${t.accent(this.state.cleanBytesCollected.toString())}`;
|
|
934
|
+
const buffs = [];
|
|
935
|
+
if (this.state.activeShield) buffs.push(t.success("[SHIELD ACTIVE]"));
|
|
936
|
+
if (this.state.slowMotionTicks > 0) buffs.push(t.warning(`[SLOW-MO ${Math.ceil(this.state.slowMotionTicks / 10)}s]`));
|
|
937
|
+
if (this.state.magnetTicks > 0) buffs.push(t.secondary(`[MAGNET ${Math.ceil(this.state.magnetTicks / 10)}s]`));
|
|
938
|
+
if (this.state.doubleScoreTicks > 0) buffs.push(t.highlight(`[2X SCORE ${Math.ceil(this.state.doubleScoreTicks / 10)}s]`));
|
|
939
|
+
hudLines.push(` ${distStr} ${bytesStr} ${buffs.join(" ")}`);
|
|
940
|
+
hudLines.push("");
|
|
941
|
+
const trackWidth = 54;
|
|
942
|
+
const laneWidth = 18;
|
|
943
|
+
const trackLines = [];
|
|
944
|
+
trackLines.push(` ${t.border("\u250C" + "\u2500".repeat(trackWidth) + "\u2510")}`);
|
|
945
|
+
for (let y = 0; y < HIGHWAY_HEIGHT; y++) {
|
|
946
|
+
let rowContent = "";
|
|
947
|
+
for (let lane = 0; lane < LANE_COUNT; lane++) {
|
|
948
|
+
const ent = this.entities.find((e) => e.lane === lane && e.y === y);
|
|
949
|
+
let cellText = " ".repeat(laneWidth);
|
|
950
|
+
if (ent) {
|
|
951
|
+
let formattedLabel = ent.label;
|
|
952
|
+
if (ent.type === "corrupt") {
|
|
953
|
+
formattedLabel = t.error(ent.label);
|
|
954
|
+
} else if (ent.type === "clean") {
|
|
955
|
+
formattedLabel = t.success(ent.label);
|
|
956
|
+
} else if (ent.type === "powerup") {
|
|
957
|
+
formattedLabel = t.highlight(ent.label);
|
|
958
|
+
}
|
|
959
|
+
const cleanLen = ent.label.length;
|
|
960
|
+
const leftPad = Math.floor((laneWidth - cleanLen) / 2);
|
|
961
|
+
const rightPad = laneWidth - cleanLen - leftPad;
|
|
962
|
+
cellText = " ".repeat(Math.max(0, leftPad)) + formattedLabel + " ".repeat(Math.max(0, rightPad));
|
|
963
|
+
}
|
|
964
|
+
if (y === HIGHWAY_HEIGHT - 2 && lane === this.state.playerLane) {
|
|
965
|
+
const avatar = this.state.isJumping ? "\u25B2 [AIRBORNE] \u25B2" : "\u25B2\u2550\u2550[RUNNER]\u2550\u2550\u25B2";
|
|
966
|
+
const colored = this.state.activeShield ? t.highlight(avatar) : t.primary(avatar);
|
|
967
|
+
const pad = Math.max(0, Math.floor((laneWidth - 14) / 2));
|
|
968
|
+
cellText = " ".repeat(pad) + colored + " ".repeat(Math.max(0, laneWidth - 14 - pad));
|
|
969
|
+
}
|
|
970
|
+
rowContent += cellText + (lane < LANE_COUNT - 1 ? t.border("\u2506") : "");
|
|
971
|
+
}
|
|
972
|
+
trackLines.push(` ${t.border("\u2502")}${rowContent}${t.border("\u2502")}`);
|
|
973
|
+
}
|
|
974
|
+
trackLines.push(` ${t.border("\u2514" + "\u2500".repeat(trackWidth) + "\u2518")}`);
|
|
975
|
+
if (this.state.isGameOver) {
|
|
976
|
+
trackLines.push(`
|
|
977
|
+
${t.error("\u{1F4A5} SYSTEM FAULT: PACKET CORRUPTED!")}`);
|
|
978
|
+
trackLines.push(` ${t.accent(`Final Distance: ${this.state.distance}m \u2502 Final Score: ${this.state.score}`)}`);
|
|
979
|
+
trackLines.push(` ${t.muted("Press R to Re-engage Runner, or Esc / Q to Exit.")}`);
|
|
980
|
+
} else {
|
|
981
|
+
trackLines.push(` ${t.muted("Controls: Left/Right: Lane \u2502 Up/Space: Jump \u2502 Esc/P: Pause \u2502 Q: Quit")}`);
|
|
982
|
+
}
|
|
983
|
+
this.renderer.clear();
|
|
984
|
+
this.renderer.draw(`
|
|
985
|
+
${header}
|
|
986
|
+
${hudLines.join("\n")}
|
|
987
|
+
${trackLines.join("\n")}
|
|
988
|
+
`);
|
|
989
|
+
}
|
|
990
|
+
getState() {
|
|
991
|
+
return this.state;
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
// src/games/level-devil/index.ts
|
|
996
|
+
var ARENA_WIDTH = 60;
|
|
997
|
+
var ARENA_HEIGHT = 12;
|
|
998
|
+
var DEVIL_TAUNTS = [
|
|
999
|
+
"Did you really think it would be that simple?",
|
|
1000
|
+
"Oops! That floor looked sturdy, did it not?",
|
|
1001
|
+
"Spikes: 1, You: 0.",
|
|
1002
|
+
"Rule #1 of Level Devil: NEVER trust the door.",
|
|
1003
|
+
"Why are you walking into danger?",
|
|
1004
|
+
"Gravity is purely a suggestion here.",
|
|
1005
|
+
"Take a deep breath and try not to rage-quit.",
|
|
1006
|
+
"Almost had it! (Not really).",
|
|
1007
|
+
"Trust issues? You have not seen anything yet."
|
|
1008
|
+
];
|
|
1009
|
+
var LEVELS = [
|
|
1010
|
+
// Level 1: "Trust Issues" - Simple jump, but as you approach the door, floor drops!
|
|
1011
|
+
{
|
|
1012
|
+
number: 1,
|
|
1013
|
+
title: "Trust Issues",
|
|
1014
|
+
taunt: "Just walk to the door. Simple, right?",
|
|
1015
|
+
playerStart: { x: 4, y: 9 },
|
|
1016
|
+
doorStart: { x: 52, y: 9 },
|
|
1017
|
+
map: [
|
|
1018
|
+
" ",
|
|
1019
|
+
" ",
|
|
1020
|
+
" ",
|
|
1021
|
+
" ",
|
|
1022
|
+
" ",
|
|
1023
|
+
" ",
|
|
1024
|
+
" ",
|
|
1025
|
+
" ",
|
|
1026
|
+
" ",
|
|
1027
|
+
" ",
|
|
1028
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1029
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1030
|
+
],
|
|
1031
|
+
traps: [
|
|
1032
|
+
{ id: 1, type: "falling-floor", triggerX: 40, triggered: false, x: 44, y: 10, width: 6 }
|
|
1033
|
+
]
|
|
1034
|
+
},
|
|
1035
|
+
// Level 2: "Pop Goes the Spike" - Hallway where hidden spikes pop up!
|
|
1036
|
+
{
|
|
1037
|
+
number: 2,
|
|
1038
|
+
title: "Pop Goes the Spike",
|
|
1039
|
+
taunt: "Watch your step. The floor is sensitive.",
|
|
1040
|
+
playerStart: { x: 4, y: 9 },
|
|
1041
|
+
doorStart: { x: 52, y: 9 },
|
|
1042
|
+
map: [
|
|
1043
|
+
" ",
|
|
1044
|
+
" ",
|
|
1045
|
+
" ",
|
|
1046
|
+
" ",
|
|
1047
|
+
" ",
|
|
1048
|
+
" ",
|
|
1049
|
+
" ",
|
|
1050
|
+
" ",
|
|
1051
|
+
" ",
|
|
1052
|
+
" ",
|
|
1053
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1054
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1055
|
+
],
|
|
1056
|
+
traps: [
|
|
1057
|
+
{ id: 2, type: "rising-spike", triggerX: 20, triggered: false, x: 23, y: 9, width: 2 },
|
|
1058
|
+
{ id: 3, type: "rising-spike", triggerX: 35, triggered: false, x: 38, y: 9, width: 2 }
|
|
1059
|
+
]
|
|
1060
|
+
},
|
|
1061
|
+
// Level 3: "Vanishing Bridge" - Middle bridge over spikes vanishes on touch!
|
|
1062
|
+
{
|
|
1063
|
+
number: 3,
|
|
1064
|
+
title: "Vanishing Bridge",
|
|
1065
|
+
taunt: "The bridge is safe. We promise.",
|
|
1066
|
+
playerStart: { x: 4, y: 9 },
|
|
1067
|
+
doorStart: { x: 52, y: 9 },
|
|
1068
|
+
map: [
|
|
1069
|
+
" ",
|
|
1070
|
+
" ",
|
|
1071
|
+
" ",
|
|
1072
|
+
" ",
|
|
1073
|
+
" ",
|
|
1074
|
+
" ",
|
|
1075
|
+
" ",
|
|
1076
|
+
" ",
|
|
1077
|
+
" ",
|
|
1078
|
+
" \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 ",
|
|
1079
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1080
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2\u25B2 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1081
|
+
],
|
|
1082
|
+
traps: [
|
|
1083
|
+
{ id: 4, type: "falling-floor", triggerX: 24, triggered: false, x: 20, y: 9, width: 12 }
|
|
1084
|
+
]
|
|
1085
|
+
},
|
|
1086
|
+
// Level 4: "Ceiling Smasher" - Huge ceiling spike slams down when jumping!
|
|
1087
|
+
{
|
|
1088
|
+
number: 4,
|
|
1089
|
+
title: "Ceiling Smasher",
|
|
1090
|
+
taunt: "Do not jump too high.",
|
|
1091
|
+
playerStart: { x: 4, y: 9 },
|
|
1092
|
+
doorStart: { x: 52, y: 9 },
|
|
1093
|
+
map: [
|
|
1094
|
+
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550",
|
|
1095
|
+
" ",
|
|
1096
|
+
" ",
|
|
1097
|
+
" ",
|
|
1098
|
+
" ",
|
|
1099
|
+
" ",
|
|
1100
|
+
" ",
|
|
1101
|
+
" ",
|
|
1102
|
+
" ",
|
|
1103
|
+
" \u25B2\u25B2 ",
|
|
1104
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1105
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1106
|
+
],
|
|
1107
|
+
traps: [
|
|
1108
|
+
{ id: 5, type: "ceiling-spike", triggerX: 20, triggered: false, x: 24, y: 1, width: 4 }
|
|
1109
|
+
]
|
|
1110
|
+
},
|
|
1111
|
+
// Level 5: "Mind Warp" - Controls invert halfway through!
|
|
1112
|
+
{
|
|
1113
|
+
number: 5,
|
|
1114
|
+
title: "Mind Warp",
|
|
1115
|
+
taunt: "Left is right, right is left. Or is it?",
|
|
1116
|
+
playerStart: { x: 4, y: 9 },
|
|
1117
|
+
doorStart: { x: 52, y: 9 },
|
|
1118
|
+
map: [
|
|
1119
|
+
" ",
|
|
1120
|
+
" ",
|
|
1121
|
+
" ",
|
|
1122
|
+
" ",
|
|
1123
|
+
" ",
|
|
1124
|
+
" ",
|
|
1125
|
+
" ",
|
|
1126
|
+
" ",
|
|
1127
|
+
" ",
|
|
1128
|
+
" \u25B2\u25B2\u25B2 \u25B2\u25B2\u25B2 ",
|
|
1129
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1130
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1131
|
+
],
|
|
1132
|
+
traps: [
|
|
1133
|
+
{ id: 6, type: "inverted-controls", triggerX: 22, triggered: false, x: 22, y: 0 }
|
|
1134
|
+
]
|
|
1135
|
+
},
|
|
1136
|
+
// Level 6: "The Cowardly Door" - Door runs away when you approach!
|
|
1137
|
+
{
|
|
1138
|
+
number: 6,
|
|
1139
|
+
title: "The Cowardly Door",
|
|
1140
|
+
taunt: "Why are you chasing the door? It is shy.",
|
|
1141
|
+
playerStart: { x: 4, y: 9 },
|
|
1142
|
+
doorStart: { x: 36, y: 9 },
|
|
1143
|
+
map: [
|
|
1144
|
+
" ",
|
|
1145
|
+
" ",
|
|
1146
|
+
" ",
|
|
1147
|
+
" ",
|
|
1148
|
+
" \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 ",
|
|
1149
|
+
" ",
|
|
1150
|
+
" ",
|
|
1151
|
+
" ",
|
|
1152
|
+
" ",
|
|
1153
|
+
" ",
|
|
1154
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1155
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1156
|
+
],
|
|
1157
|
+
traps: [
|
|
1158
|
+
{ id: 7, type: "runaway-door", triggerX: 30, triggered: false, x: 36, y: 9, targetX: 48, targetY: 3 },
|
|
1159
|
+
{ id: 12, type: "runaway-door", triggerX: 44, triggered: false, x: 48, y: 3, targetX: 54, targetY: 9 }
|
|
1160
|
+
]
|
|
1161
|
+
},
|
|
1162
|
+
// Level 7: "Anti-Gravity" - Floor pad flips gravity to the ceiling!
|
|
1163
|
+
{
|
|
1164
|
+
number: 7,
|
|
1165
|
+
title: "Anti-Gravity",
|
|
1166
|
+
taunt: "Up is down, down is up. Enjoy the ceiling.",
|
|
1167
|
+
playerStart: { x: 4, y: 9 },
|
|
1168
|
+
doorStart: { x: 52, y: 2 },
|
|
1169
|
+
map: [
|
|
1170
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1171
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1172
|
+
" \u25BC\u25BC\u25BC\u25BC ",
|
|
1173
|
+
" ",
|
|
1174
|
+
" ",
|
|
1175
|
+
" ",
|
|
1176
|
+
" ",
|
|
1177
|
+
" ",
|
|
1178
|
+
" ",
|
|
1179
|
+
" \u2591\u2591 ",
|
|
1180
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1181
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1182
|
+
],
|
|
1183
|
+
traps: [
|
|
1184
|
+
{ id: 8, type: "gravity-pad", triggerX: 18, triggered: false, x: 18, y: 9 }
|
|
1185
|
+
]
|
|
1186
|
+
},
|
|
1187
|
+
// Level 8: "The Final Betrayal" - Falling floor + rising spike + running door gauntlet!
|
|
1188
|
+
{
|
|
1189
|
+
number: 8,
|
|
1190
|
+
title: "The Final Betrayal",
|
|
1191
|
+
taunt: "Everything you have learned is a lie.",
|
|
1192
|
+
playerStart: { x: 4, y: 9 },
|
|
1193
|
+
doorStart: { x: 46, y: 9 },
|
|
1194
|
+
map: [
|
|
1195
|
+
" ",
|
|
1196
|
+
" ",
|
|
1197
|
+
" ",
|
|
1198
|
+
" ",
|
|
1199
|
+
" \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 ",
|
|
1200
|
+
" ",
|
|
1201
|
+
" ",
|
|
1202
|
+
" ",
|
|
1203
|
+
" ",
|
|
1204
|
+
" ",
|
|
1205
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
|
|
1206
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
|
|
1207
|
+
],
|
|
1208
|
+
traps: [
|
|
1209
|
+
{ id: 9, type: "rising-spike", triggerX: 18, triggered: false, x: 22, y: 9, width: 2 },
|
|
1210
|
+
{ id: 10, type: "falling-floor", triggerX: 30, triggered: false, x: 34, y: 10, width: 6 },
|
|
1211
|
+
{ id: 11, type: "runaway-door", triggerX: 42, triggered: false, x: 46, y: 9, targetX: 52, targetY: 3 }
|
|
1212
|
+
]
|
|
1213
|
+
}
|
|
1214
|
+
];
|
|
1215
|
+
var LevelDevilGame = class {
|
|
1216
|
+
id = "level-devil";
|
|
1217
|
+
metadata = ALL_GAMES_METADATA["level-devil"];
|
|
1218
|
+
config = null;
|
|
1219
|
+
renderer = defaultRenderer;
|
|
1220
|
+
input = new TerminalInputHandler();
|
|
1221
|
+
rng = new DeterministicRNG();
|
|
1222
|
+
gameLoopTimer = null;
|
|
1223
|
+
tickIntervalMs = 45;
|
|
1224
|
+
// Smooth 22 FPS physics
|
|
1225
|
+
state = {
|
|
1226
|
+
currentLevel: 1,
|
|
1227
|
+
deaths: 0,
|
|
1228
|
+
levelDeaths: 0,
|
|
1229
|
+
playerX: 4,
|
|
1230
|
+
playerY: 9,
|
|
1231
|
+
playerVx: 0,
|
|
1232
|
+
playerVy: 0,
|
|
1233
|
+
isGrounded: true,
|
|
1234
|
+
doorX: 52,
|
|
1235
|
+
doorY: 9,
|
|
1236
|
+
doorOpen: false,
|
|
1237
|
+
gravityFlipped: false,
|
|
1238
|
+
controlsInverted: false,
|
|
1239
|
+
activeTraps: [],
|
|
1240
|
+
dynamicTiles: {},
|
|
1241
|
+
isLevelComplete: false,
|
|
1242
|
+
isGameWon: false,
|
|
1243
|
+
isGameOver: false,
|
|
1244
|
+
isDying: false,
|
|
1245
|
+
deathTicks: 0,
|
|
1246
|
+
tauntText: "Just walk to the door. Simple, right?"
|
|
1247
|
+
};
|
|
1248
|
+
isPaused = false;
|
|
1249
|
+
pauseMenuIndex = 0;
|
|
1250
|
+
showTutorial = true;
|
|
1251
|
+
init(config) {
|
|
1252
|
+
this.config = config;
|
|
1253
|
+
this.renderer.setTheme(config.theme);
|
|
1254
|
+
this.rng = new DeterministicRNG(config.seed || Date.now());
|
|
1255
|
+
if (config.skipTutorial !== void 0) {
|
|
1256
|
+
this.showTutorial = !config.skipTutorial;
|
|
1257
|
+
}
|
|
1258
|
+
this.loadLevel(1);
|
|
1259
|
+
}
|
|
1260
|
+
start() {
|
|
1261
|
+
this.isPaused = false;
|
|
1262
|
+
this.render();
|
|
1263
|
+
this.input.start(
|
|
1264
|
+
(key) => this.handleInput(key),
|
|
1265
|
+
() => {
|
|
1266
|
+
this.destroy();
|
|
1267
|
+
this.config?.onExit?.();
|
|
1268
|
+
}
|
|
1269
|
+
);
|
|
1270
|
+
if (!this.showTutorial) {
|
|
1271
|
+
this.scheduleNextTick();
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
pause() {
|
|
1275
|
+
this.isPaused = true;
|
|
1276
|
+
if (this.gameLoopTimer) {
|
|
1277
|
+
clearTimeout(this.gameLoopTimer);
|
|
1278
|
+
this.gameLoopTimer = null;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
resume() {
|
|
1282
|
+
this.isPaused = false;
|
|
1283
|
+
this.scheduleNextTick();
|
|
1284
|
+
}
|
|
1285
|
+
restart() {
|
|
1286
|
+
this.loadLevel(this.state.currentLevel);
|
|
1287
|
+
this.render();
|
|
1288
|
+
this.scheduleNextTick();
|
|
1289
|
+
}
|
|
1290
|
+
saveState() {
|
|
1291
|
+
return {
|
|
1292
|
+
state: this.state,
|
|
1293
|
+
showTutorial: this.showTutorial
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
loadState(saved) {
|
|
1297
|
+
if (saved["state"]) this.state = saved["state"];
|
|
1298
|
+
if (saved["showTutorial"] !== void 0) this.showTutorial = !!saved["showTutorial"];
|
|
1299
|
+
}
|
|
1300
|
+
getState() {
|
|
1301
|
+
return this.state;
|
|
1302
|
+
}
|
|
1303
|
+
handleInputForTest(key) {
|
|
1304
|
+
this.handleInput(key);
|
|
1305
|
+
}
|
|
1306
|
+
destroy() {
|
|
1307
|
+
if (this.gameLoopTimer) {
|
|
1308
|
+
clearTimeout(this.gameLoopTimer);
|
|
1309
|
+
this.gameLoopTimer = null;
|
|
1310
|
+
}
|
|
1311
|
+
this.input.stop();
|
|
1312
|
+
}
|
|
1313
|
+
loadLevel(levelNum) {
|
|
1314
|
+
const lvlIdx = Math.max(0, Math.min(LEVELS.length - 1, levelNum - 1));
|
|
1315
|
+
const lvl = LEVELS[lvlIdx];
|
|
1316
|
+
this.state.currentLevel = lvl.number;
|
|
1317
|
+
this.state.levelDeaths = 0;
|
|
1318
|
+
this.state.playerX = lvl.playerStart.x;
|
|
1319
|
+
this.state.playerY = lvl.playerStart.y;
|
|
1320
|
+
this.state.playerVx = 0;
|
|
1321
|
+
this.state.playerVy = 0;
|
|
1322
|
+
this.state.isGrounded = true;
|
|
1323
|
+
this.state.doorX = lvl.doorStart.x;
|
|
1324
|
+
this.state.doorY = lvl.doorStart.y;
|
|
1325
|
+
this.state.doorOpen = false;
|
|
1326
|
+
this.state.gravityFlipped = false;
|
|
1327
|
+
this.state.controlsInverted = false;
|
|
1328
|
+
this.state.activeTraps = JSON.parse(JSON.stringify(lvl.traps));
|
|
1329
|
+
this.state.dynamicTiles = {};
|
|
1330
|
+
this.state.isLevelComplete = false;
|
|
1331
|
+
this.state.isDying = false;
|
|
1332
|
+
this.state.deathTicks = 0;
|
|
1333
|
+
this.state.tauntText = lvl.taunt;
|
|
1334
|
+
}
|
|
1335
|
+
triggerDeath() {
|
|
1336
|
+
if (this.state.isDying) return;
|
|
1337
|
+
this.state.deaths++;
|
|
1338
|
+
this.state.levelDeaths++;
|
|
1339
|
+
this.state.isDying = true;
|
|
1340
|
+
this.state.deathTicks = 3;
|
|
1341
|
+
if (this.state.deaths === 1) {
|
|
1342
|
+
this.config?.onAchievementUnlock?.("first_betrayal");
|
|
1343
|
+
}
|
|
1344
|
+
const randTaunt = DEVIL_TAUNTS[Math.floor(this.rng.next() * DEVIL_TAUNTS.length)];
|
|
1345
|
+
this.state.tauntText = randTaunt;
|
|
1346
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1347
|
+
}
|
|
1348
|
+
scheduleNextTick() {
|
|
1349
|
+
if (this.isPaused || this.state.isGameOver || this.showTutorial) return;
|
|
1350
|
+
this.gameLoopTimer = setTimeout(() => {
|
|
1351
|
+
this.tick();
|
|
1352
|
+
this.scheduleNextTick();
|
|
1353
|
+
}, this.tickIntervalMs);
|
|
1354
|
+
}
|
|
1355
|
+
tick() {
|
|
1356
|
+
if (this.isPaused || this.showTutorial || this.state.isGameWon) return;
|
|
1357
|
+
if (this.state.isDying) {
|
|
1358
|
+
this.state.deathTicks--;
|
|
1359
|
+
if (this.state.deathTicks <= 0) {
|
|
1360
|
+
const lvl = LEVELS[this.state.currentLevel - 1];
|
|
1361
|
+
this.state.playerX = lvl.playerStart.x;
|
|
1362
|
+
this.state.playerY = lvl.playerStart.y;
|
|
1363
|
+
this.state.playerVx = 0;
|
|
1364
|
+
this.state.playerVy = 0;
|
|
1365
|
+
this.state.isGrounded = true;
|
|
1366
|
+
this.state.gravityFlipped = false;
|
|
1367
|
+
this.state.controlsInverted = false;
|
|
1368
|
+
this.state.activeTraps = JSON.parse(JSON.stringify(lvl.traps));
|
|
1369
|
+
this.state.dynamicTiles = {};
|
|
1370
|
+
this.state.doorX = lvl.doorStart.x;
|
|
1371
|
+
this.state.doorY = lvl.doorStart.y;
|
|
1372
|
+
this.state.isDying = false;
|
|
1373
|
+
}
|
|
1374
|
+
this.render();
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
const px = Math.round(this.state.playerX);
|
|
1378
|
+
for (const trap of this.state.activeTraps) {
|
|
1379
|
+
if (!trap.triggered && px >= trap.triggerX) {
|
|
1380
|
+
trap.triggered = true;
|
|
1381
|
+
this.activateTrap(trap);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
const grav = this.state.gravityFlipped ? -0.22 : 0.22;
|
|
1385
|
+
this.state.playerVy += grav;
|
|
1386
|
+
this.state.playerX += this.state.playerVx;
|
|
1387
|
+
this.state.playerY += this.state.playerVy;
|
|
1388
|
+
if (this.state.isGrounded) {
|
|
1389
|
+
this.state.playerVx *= 0.65;
|
|
1390
|
+
} else {
|
|
1391
|
+
this.state.playerVx *= 0.92;
|
|
1392
|
+
}
|
|
1393
|
+
if (Math.abs(this.state.playerVx) < 0.05) this.state.playerVx = 0;
|
|
1394
|
+
if (this.state.playerX < 1) this.state.playerX = 1;
|
|
1395
|
+
if (this.state.playerX > ARENA_WIDTH - 2) this.state.playerX = ARENA_WIDTH - 2;
|
|
1396
|
+
this.resolveCollisions();
|
|
1397
|
+
const intPx = Math.round(this.state.playerX);
|
|
1398
|
+
const intPy = Math.round(this.state.playerY);
|
|
1399
|
+
if (Math.abs(intPx - this.state.doorX) <= 1 && Math.abs(intPy - this.state.doorY) <= 1) {
|
|
1400
|
+
this.advanceLevel();
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (this.state.playerY >= ARENA_HEIGHT || this.state.playerY < 0) {
|
|
1404
|
+
this.triggerDeath();
|
|
1405
|
+
}
|
|
1406
|
+
this.render();
|
|
1407
|
+
}
|
|
1408
|
+
activateTrap(trap) {
|
|
1409
|
+
if (trap.type === "rising-spike") {
|
|
1410
|
+
const width = trap.width || 2;
|
|
1411
|
+
for (let w = 0; w < width; w++) {
|
|
1412
|
+
this.state.dynamicTiles[`${trap.x + w},${trap.y}`] = "\u25B2";
|
|
1413
|
+
}
|
|
1414
|
+
} else if (trap.type === "falling-floor") {
|
|
1415
|
+
const width = trap.width || 6;
|
|
1416
|
+
for (let w = 0; w < width; w++) {
|
|
1417
|
+
this.state.dynamicTiles[`${trap.x + w},${trap.y}`] = " ";
|
|
1418
|
+
if (trap.y === 10) {
|
|
1419
|
+
this.state.dynamicTiles[`${trap.x + w},11`] = " ";
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
} else if (trap.type === "ceiling-spike") {
|
|
1423
|
+
const width = trap.width || 4;
|
|
1424
|
+
for (let w = 0; w < width; w++) {
|
|
1425
|
+
for (let dy = 1; dy <= 7; dy++) {
|
|
1426
|
+
this.state.dynamicTiles[`${trap.x + w},${trap.y + dy}`] = "\u25BC";
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
} else if (trap.type === "inverted-controls") {
|
|
1430
|
+
this.state.controlsInverted = true;
|
|
1431
|
+
this.state.tauntText = "\u26A0 CONTROLS INVERTED! LEFT IS RIGHT! \u26A0";
|
|
1432
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1433
|
+
} else if (trap.type === "gravity-pad") {
|
|
1434
|
+
this.state.gravityFlipped = true;
|
|
1435
|
+
this.state.tauntText = "\u{1F300} GRAVITY FLIPPED! YOU WALK ON THE CEILING!";
|
|
1436
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1437
|
+
} else if (trap.type === "runaway-door") {
|
|
1438
|
+
if (trap.targetX !== void 0 && trap.targetY !== void 0) {
|
|
1439
|
+
this.state.doorX = trap.targetX;
|
|
1440
|
+
this.state.doorY = trap.targetY;
|
|
1441
|
+
this.state.tauntText = "NOPE! The door ran away!";
|
|
1442
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
getTileAt(x, y) {
|
|
1447
|
+
const key = `${x},${y}`;
|
|
1448
|
+
if (this.state.dynamicTiles[key] !== void 0) {
|
|
1449
|
+
return this.state.dynamicTiles[key];
|
|
1450
|
+
}
|
|
1451
|
+
const lvl = LEVELS[this.state.currentLevel - 1];
|
|
1452
|
+
if (!lvl || y < 0 || y >= lvl.map.length) return " ";
|
|
1453
|
+
const row = lvl.map[y];
|
|
1454
|
+
if (!row || x < 0 || x >= row.length) return " ";
|
|
1455
|
+
return row[x] || " ";
|
|
1456
|
+
}
|
|
1457
|
+
resolveCollisions() {
|
|
1458
|
+
const px = Math.round(this.state.playerX);
|
|
1459
|
+
const py = Math.round(this.state.playerY);
|
|
1460
|
+
const currentTile = this.getTileAt(px, py);
|
|
1461
|
+
if (currentTile === "\u25B2" || currentTile === "\u25BC" || currentTile === "\u203B") {
|
|
1462
|
+
this.triggerDeath();
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
if (this.state.playerVx > 0) {
|
|
1466
|
+
const tileRight = this.getTileAt(px + 1, py);
|
|
1467
|
+
if (tileRight === "\u2588" || tileRight === "\u2550") {
|
|
1468
|
+
this.state.playerVx = 0;
|
|
1469
|
+
}
|
|
1470
|
+
} else if (this.state.playerVx < 0) {
|
|
1471
|
+
const tileLeft = this.getTileAt(px - 1, py);
|
|
1472
|
+
if (tileLeft === "\u2588" || tileLeft === "\u2550") {
|
|
1473
|
+
this.state.playerVx = 0;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
if (!this.state.gravityFlipped) {
|
|
1477
|
+
const tileBelow = this.getTileAt(px, py + 1);
|
|
1478
|
+
if (tileBelow === "\u2588" || tileBelow === "\u2550") {
|
|
1479
|
+
this.state.playerY = py;
|
|
1480
|
+
this.state.playerVy = 0;
|
|
1481
|
+
this.state.isGrounded = true;
|
|
1482
|
+
} else {
|
|
1483
|
+
this.state.isGrounded = false;
|
|
1484
|
+
}
|
|
1485
|
+
const tileAbove = this.getTileAt(px, py - 1);
|
|
1486
|
+
if (tileAbove === "\u2588" || tileAbove === "\u2550") {
|
|
1487
|
+
if (this.state.playerVy < 0) this.state.playerVy = 0;
|
|
1488
|
+
} else if (tileAbove === "\u25B2" || tileAbove === "\u25BC") {
|
|
1489
|
+
this.triggerDeath();
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
} else {
|
|
1493
|
+
const tileAbove = this.getTileAt(px, py - 1);
|
|
1494
|
+
if (tileAbove === "\u2588" || tileAbove === "\u2550") {
|
|
1495
|
+
this.state.playerY = py;
|
|
1496
|
+
this.state.playerVy = 0;
|
|
1497
|
+
this.state.isGrounded = true;
|
|
1498
|
+
} else {
|
|
1499
|
+
this.state.isGrounded = false;
|
|
1500
|
+
}
|
|
1501
|
+
const tileBelow = this.getTileAt(px, py + 1);
|
|
1502
|
+
if (tileBelow === "\u2588" || tileBelow === "\u2550") {
|
|
1503
|
+
if (this.state.playerVy > 0) this.state.playerVy = 0;
|
|
1504
|
+
} else if (tileBelow === "\u25B2" || tileBelow === "\u25BC") {
|
|
1505
|
+
this.triggerDeath();
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
advanceLevel() {
|
|
1511
|
+
if (this.state.currentLevel === 4) {
|
|
1512
|
+
this.config?.onAchievementUnlock?.("midway_survivor");
|
|
1513
|
+
}
|
|
1514
|
+
if (this.state.currentLevel >= LEVELS.length) {
|
|
1515
|
+
this.state.isGameWon = true;
|
|
1516
|
+
this.config?.onAchievementUnlock?.("devil_conquered");
|
|
1517
|
+
this.config?.onGameOver?.(Math.max(0, 1e3 - this.state.deaths * 25));
|
|
1518
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1519
|
+
this.render();
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
this.loadLevel(this.state.currentLevel + 1);
|
|
1523
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1524
|
+
this.render();
|
|
1525
|
+
}
|
|
1526
|
+
handleInput(key) {
|
|
1527
|
+
if (this.showTutorial) {
|
|
1528
|
+
if (key.name === "return" || key.name === "space") {
|
|
1529
|
+
this.showTutorial = false;
|
|
1530
|
+
this.scheduleNextTick();
|
|
1531
|
+
this.render();
|
|
1532
|
+
} else if (key.name === "escape" || key.name === "q") {
|
|
1533
|
+
this.destroy();
|
|
1534
|
+
this.config?.onExit?.();
|
|
1535
|
+
}
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
if (this.isPaused) {
|
|
1539
|
+
if (key.name === "up" || key.name === "w") {
|
|
1540
|
+
this.pauseMenuIndex = (this.pauseMenuIndex - 1 + 3) % 3;
|
|
1541
|
+
this.render();
|
|
1542
|
+
} else if (key.name === "down" || key.name === "s") {
|
|
1543
|
+
this.pauseMenuIndex = (this.pauseMenuIndex + 1) % 3;
|
|
1544
|
+
this.render();
|
|
1545
|
+
} else if (key.name === "return" || key.name === "space") {
|
|
1546
|
+
if (this.pauseMenuIndex === 0) {
|
|
1547
|
+
this.isPaused = false;
|
|
1548
|
+
this.scheduleNextTick();
|
|
1549
|
+
this.render();
|
|
1550
|
+
} else if (this.pauseMenuIndex === 1) {
|
|
1551
|
+
this.isPaused = false;
|
|
1552
|
+
this.restart();
|
|
1553
|
+
} else if (this.pauseMenuIndex === 2) {
|
|
1554
|
+
this.destroy();
|
|
1555
|
+
this.config?.onExit?.();
|
|
1556
|
+
}
|
|
1557
|
+
} else if (key.name === "escape" || key.name === "p") {
|
|
1558
|
+
this.isPaused = false;
|
|
1559
|
+
this.scheduleNextTick();
|
|
1560
|
+
this.render();
|
|
1561
|
+
} else if (key.name === "q") {
|
|
1562
|
+
this.destroy();
|
|
1563
|
+
this.config?.onExit?.();
|
|
1564
|
+
}
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
if (key.name === "escape" || key.name === "p") {
|
|
1568
|
+
this.isPaused = true;
|
|
1569
|
+
this.pauseMenuIndex = 0;
|
|
1570
|
+
if (this.gameLoopTimer) {
|
|
1571
|
+
clearTimeout(this.gameLoopTimer);
|
|
1572
|
+
this.gameLoopTimer = null;
|
|
1573
|
+
}
|
|
1574
|
+
this.render();
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
if (key.name === "q") {
|
|
1578
|
+
this.destroy();
|
|
1579
|
+
this.config?.onExit?.();
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
if (key.name === "r") {
|
|
1583
|
+
this.restart();
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
if (this.state.isGameWon) {
|
|
1587
|
+
if (key.name === "return" || key.name === "space" || key.name === "r") {
|
|
1588
|
+
this.state.deaths = 0;
|
|
1589
|
+
this.loadLevel(1);
|
|
1590
|
+
this.render();
|
|
1591
|
+
this.scheduleNextTick();
|
|
1592
|
+
}
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
const moveLeft = this.state.controlsInverted ? key.name === "right" || key.name === "d" : key.name === "left" || key.name === "a";
|
|
1596
|
+
const moveRight = this.state.controlsInverted ? key.name === "left" || key.name === "a" : key.name === "right" || key.name === "d";
|
|
1597
|
+
if (moveLeft) {
|
|
1598
|
+
this.state.playerVx = this.state.isGrounded ? -1.05 : -0.85;
|
|
1599
|
+
this.state.playerX -= 0.5;
|
|
1600
|
+
if (this.state.playerX < 1) this.state.playerX = 1;
|
|
1601
|
+
this.resolveCollisions();
|
|
1602
|
+
this.render();
|
|
1603
|
+
} else if (moveRight) {
|
|
1604
|
+
this.state.playerVx = this.state.isGrounded ? 1.05 : 0.85;
|
|
1605
|
+
this.state.playerX += 0.5;
|
|
1606
|
+
if (this.state.playerX > ARENA_WIDTH - 2) this.state.playerX = ARENA_WIDTH - 2;
|
|
1607
|
+
this.resolveCollisions();
|
|
1608
|
+
this.render();
|
|
1609
|
+
}
|
|
1610
|
+
if (key.name === "space" || key.name === "up" || key.name === "w") {
|
|
1611
|
+
if (this.state.isGrounded) {
|
|
1612
|
+
this.state.playerVy = this.state.gravityFlipped ? 1.35 : -1.35;
|
|
1613
|
+
this.state.playerY += this.state.gravityFlipped ? 0.35 : -0.35;
|
|
1614
|
+
this.state.isGrounded = false;
|
|
1615
|
+
if (this.config?.soundEnabled) playTerminalBell();
|
|
1616
|
+
this.render();
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if (key.name === "down" || key.name === "s") {
|
|
1620
|
+
if (!this.state.isGrounded) {
|
|
1621
|
+
this.state.playerVy = this.state.gravityFlipped ? -1.35 : 1.35;
|
|
1622
|
+
this.render();
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
render() {
|
|
1627
|
+
const t = this.renderer.getTheme();
|
|
1628
|
+
const totalWidth = ARENA_WIDTH + 2;
|
|
1629
|
+
if (this.showTutorial) {
|
|
1630
|
+
const lines = [
|
|
1631
|
+
"",
|
|
1632
|
+
t.highlight("LEVEL DEVIL // SURVIVAL PROTOCOL"),
|
|
1633
|
+
"",
|
|
1634
|
+
"\u2022 Your only objective is to step through the EXIT DOOR.",
|
|
1635
|
+
"\u2022 BUT: Expect betrayal. Nothing is what it seems.",
|
|
1636
|
+
"\u2022 Spikes pop up. Floors vanish beneath your feet.",
|
|
1637
|
+
"\u2022 The door will run away. Controls will invert.",
|
|
1638
|
+
"\u2022 Tap R at any time to instantly retry.",
|
|
1639
|
+
"",
|
|
1640
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
1641
|
+
t.primary("Press Space or Enter to begin \u2502 Q to Return to Game List")
|
|
1642
|
+
];
|
|
1643
|
+
const box = this.renderer.createBox(lines, 64, "LEVEL DEVIL MANUAL");
|
|
1644
|
+
this.renderer.renderFrame(this.renderer.centerBlock(box, 64));
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
if (this.isPaused) {
|
|
1648
|
+
const pauseItems = ["Resume Run (Esc / Enter)", "Restart Level (R)", "Return to Game List (Q)"];
|
|
1649
|
+
const pauseLines = [
|
|
1650
|
+
"",
|
|
1651
|
+
t.highlight("\u2550\u2550\u2550 LEVEL DEVIL PAUSED \u2550\u2550\u2550"),
|
|
1652
|
+
"",
|
|
1653
|
+
...pauseItems.map((item, idx) => {
|
|
1654
|
+
if (idx === this.pauseMenuIndex) {
|
|
1655
|
+
return t.primary(` \u25B6 ${t.highlight(item)}`);
|
|
1656
|
+
}
|
|
1657
|
+
return t.muted(` ${item}`);
|
|
1658
|
+
}),
|
|
1659
|
+
"",
|
|
1660
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
1661
|
+
t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Q: Return to Game List")
|
|
1662
|
+
];
|
|
1663
|
+
const pauseBox = this.renderer.createBox(pauseLines, 64, "SYSTEM PAUSE");
|
|
1664
|
+
this.renderer.renderFrame(this.renderer.centerBlock(pauseBox, 64));
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
if (this.state.isGameWon) {
|
|
1668
|
+
const rating = this.state.deaths <= 5 ? "DEVIL SLAYER (GOD TIER)" : this.state.deaths <= 20 ? "TACTICAL GENIUS" : this.state.deaths <= 50 ? "RAGE MASTER" : "KEYBOARD SMASHER";
|
|
1669
|
+
const winLines = [
|
|
1670
|
+
"",
|
|
1671
|
+
t.highlight("\u2605 YOU CONQUERED THE LEVEL DEVIL! \u2605"),
|
|
1672
|
+
"",
|
|
1673
|
+
`${t.muted("Total Deaths:")} ${t.accent(this.state.deaths.toString())}`,
|
|
1674
|
+
`${t.muted("Final Rating:")} ${t.success(rating)}`,
|
|
1675
|
+
"",
|
|
1676
|
+
t.secondary("You endured falling floors, runaway doors, and mind warps!"),
|
|
1677
|
+
"",
|
|
1678
|
+
t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
|
|
1679
|
+
t.primary("Press Enter or R to Play Again \u2502 Q: Return to Game List")
|
|
1680
|
+
];
|
|
1681
|
+
const winBox = this.renderer.createBox(winLines, 64, "VICTORY ARCHIVE");
|
|
1682
|
+
this.renderer.renderFrame(this.renderer.centerBlock(winBox, 64));
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
const lvl = LEVELS[this.state.currentLevel - 1];
|
|
1686
|
+
const header = this.renderer.renderHeader({
|
|
1687
|
+
title: `LEVEL DEVIL [${lvl.number}/8: ${lvl.title.toUpperCase()}]`,
|
|
1688
|
+
category: "RAGE",
|
|
1689
|
+
difficulty: this.config?.difficulty,
|
|
1690
|
+
score: this.state.deaths
|
|
1691
|
+
}, totalWidth);
|
|
1692
|
+
const grid = [];
|
|
1693
|
+
for (let y = 0; y < ARENA_HEIGHT; y++) {
|
|
1694
|
+
const row = [];
|
|
1695
|
+
for (let x = 0; x < ARENA_WIDTH; x++) {
|
|
1696
|
+
row.push(this.getTileAt(x, y));
|
|
1697
|
+
}
|
|
1698
|
+
grid.push(row);
|
|
1699
|
+
}
|
|
1700
|
+
const dx = this.state.doorX;
|
|
1701
|
+
const dy = this.state.doorY;
|
|
1702
|
+
if (dy >= 0 && dy < ARENA_HEIGHT && dx >= 0 && dx + 2 < ARENA_WIDTH) {
|
|
1703
|
+
grid[dy][dx] = "[";
|
|
1704
|
+
grid[dy][dx + 1] = "D";
|
|
1705
|
+
grid[dy][dx + 2] = "]";
|
|
1706
|
+
}
|
|
1707
|
+
const px = Math.round(this.state.playerX);
|
|
1708
|
+
const py = Math.round(this.state.playerY);
|
|
1709
|
+
if (py >= 0 && py < ARENA_HEIGHT && px >= 0 && px < ARENA_WIDTH) {
|
|
1710
|
+
grid[py][px] = this.state.isDying ? "\u{1F4A5}" : "\u25A3";
|
|
1711
|
+
}
|
|
1712
|
+
const arenaLines = [
|
|
1713
|
+
t.border("\u250C" + "\u2500".repeat(ARENA_WIDTH) + "\u2510"),
|
|
1714
|
+
...grid.map((row) => {
|
|
1715
|
+
const coloredRow = row.map((ch) => {
|
|
1716
|
+
if (ch === "\u2588" || ch === "\u2550") return t.border(ch);
|
|
1717
|
+
if (ch === "\u25B2" || ch === "\u25BC" || ch === "\u203B") return t.error(ch);
|
|
1718
|
+
if (ch === "\u25A3") return t.highlight(ch);
|
|
1719
|
+
if (ch === "\u{1F4A5}") return t.error(ch);
|
|
1720
|
+
if (ch === "[" || ch === "]" || ch === "D") return t.success(ch);
|
|
1721
|
+
if (ch === "\u2591") return t.secondary(ch);
|
|
1722
|
+
return ch;
|
|
1723
|
+
}).join("");
|
|
1724
|
+
return `${t.border("\u2502")}${coloredRow}${t.border("\u2502")}`;
|
|
1725
|
+
}),
|
|
1726
|
+
t.border("\u2514" + "\u2500".repeat(ARENA_WIDTH) + "\u2518")
|
|
1727
|
+
];
|
|
1728
|
+
const hud = ` ${t.error("DEVIL:")} "${t.secondary(this.state.tauntText)}" ${t.muted("Deaths:")} ${t.accent(this.state.deaths.toString())}`;
|
|
1729
|
+
const controls = ` ${t.muted("A/D / \u2190/\u2192: Move \u2502 Space/W: Jump \u2502 R: Retry \u2502 Q: Exit")}`;
|
|
1730
|
+
const fullCanvas = `${header}
|
|
1731
|
+
${hud}
|
|
1732
|
+
${arenaLines.join("\n")}
|
|
1733
|
+
${controls}`;
|
|
1734
|
+
this.renderer.renderFrame(this.renderer.centerBlock(fullCanvas, totalWidth));
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
34
1737
|
export {
|
|
35
1738
|
ALL_GAMES_METADATA,
|
|
36
1739
|
APP_NAME,
|
|
@@ -39,8 +1742,14 @@ export {
|
|
|
39
1742
|
AchievementManager,
|
|
40
1743
|
ArcadeMenu,
|
|
41
1744
|
ByteRunnerGame,
|
|
1745
|
+
Cyber2048Game,
|
|
1746
|
+
CyberBreakoutGame,
|
|
1747
|
+
CyberDinoGame,
|
|
1748
|
+
CyberTowerGame,
|
|
42
1749
|
CyberViperGame,
|
|
43
1750
|
DeterministicRNG,
|
|
1751
|
+
HashMatrixGame,
|
|
1752
|
+
LevelDevilGame,
|
|
44
1753
|
MIN_TERMINAL_COLUMNS,
|
|
45
1754
|
MIN_TERMINAL_ROWS,
|
|
46
1755
|
NeonCircuitGame,
|
|
@@ -52,6 +1761,7 @@ export {
|
|
|
52
1761
|
TerminullEngine,
|
|
53
1762
|
UserProfileSchema,
|
|
54
1763
|
UserSettingsSchema,
|
|
1764
|
+
VoidInvadersGame,
|
|
55
1765
|
checkTerminalDimensions,
|
|
56
1766
|
clamp,
|
|
57
1767
|
defaultAchievements,
|
|
@@ -60,7 +1770,11 @@ export {
|
|
|
60
1770
|
defaultStorage,
|
|
61
1771
|
formatTime,
|
|
62
1772
|
getTheme,
|
|
63
|
-
|
|
64
|
-
|
|
1773
|
+
padRightVisible,
|
|
1774
|
+
playArcadeLoadingScreen,
|
|
1775
|
+
playTerminalBell,
|
|
1776
|
+
stripAnsi,
|
|
1777
|
+
visibleLength,
|
|
1778
|
+
wordWrap
|
|
65
1779
|
};
|
|
66
1780
|
//# sourceMappingURL=index.js.map
|