terminull-arcade 1.0.2 → 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/index.js CHANGED
@@ -6,6 +6,10 @@ import {
6
6
  APP_VERSION,
7
7
  AchievementManager,
8
8
  ArcadeMenu,
9
+ Cyber2048Game,
10
+ CyberBreakoutGame,
11
+ CyberDinoGame,
12
+ CyberTowerGame,
9
13
  CyberViperGame,
10
14
  DeterministicRNG,
11
15
  HashMatrixGame,
@@ -34,7 +38,7 @@ import {
34
38
  stripAnsi,
35
39
  visibleLength,
36
40
  wordWrap
37
- } from "./chunk-BIOTUQT7.js";
41
+ } from "./chunk-EQAKR7UF.js";
38
42
 
39
43
  // src/games/neon-circuit/index.ts
40
44
  var NeonCircuitGame = class {
@@ -987,6 +991,749 @@ ${trackLines.join("\n")}
987
991
  return this.state;
988
992
  }
989
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
+ };
990
1737
  export {
991
1738
  ALL_GAMES_METADATA,
992
1739
  APP_NAME,
@@ -995,9 +1742,14 @@ export {
995
1742
  AchievementManager,
996
1743
  ArcadeMenu,
997
1744
  ByteRunnerGame,
1745
+ Cyber2048Game,
1746
+ CyberBreakoutGame,
1747
+ CyberDinoGame,
1748
+ CyberTowerGame,
998
1749
  CyberViperGame,
999
1750
  DeterministicRNG,
1000
1751
  HashMatrixGame,
1752
+ LevelDevilGame,
1001
1753
  MIN_TERMINAL_COLUMNS,
1002
1754
  MIN_TERMINAL_ROWS,
1003
1755
  NeonCircuitGame,