User prompt
Make infinite levels!
User prompt
Pick the random maze after you complete the first level.
User prompt
When you click start level 2, puts you on to new level.
User prompt
Make a second level, when you complete the first level and reach the cell, it has an option to go to level 2, then let me make the level 2.
User prompt
Makes the player faster.
User prompt
DECREASE PLAYER SPEED
User prompt
some reason it moves me in different directions the ones that i don't want to go in so wherever you click make it go in the exact direction that you click
User prompt
Gwnewch y chwaraewr yn fwy cyflym.
User prompt
Make less enemies.
User prompt
Make enemies slower.
User prompt
Makes the maze a little bit easier.
User prompt
Make the doors visible.
User prompt
The maze have doors and when you click on the doors they open up.
User prompt
Add all the monsters in, like the skeleton, the zombie skeleton, all them.
User prompt
Make the monsters move.
User prompt
Please fix the bug: 'ReferenceError: charNode is not defined' in or related to this line: 'var dx = targetX - charNode.x;' Line Number: 509
User prompt
Remove that code.
User prompt
Switch skeleton class with Eggsy.
User prompt
Switch skeleton class with player.
User prompt
Switch the player with the skeleton class.
User prompt
Add a main player.
User prompt
Remove the code about the golden zombie.
User prompt
Get rid of the code about the zombie!
User prompt
Six bug L172
User prompt
Fix this bug that's happening.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Monster class for AI movement and attack var Monster = Container.expand(function () { var self = Container.call(this); self.type = null; self.col = 0; self.row = 0; self.targetCol = 0; self.targetRow = 0; self.lastCol = 0; self.lastRow = 0; self.moveSpeed = 8; // px per frame, slower than player self.path = null; self.pathStepIndex = 0; self.isMoving = false; self.attackCooldown = 0; self.attackDelay = 60; // frames between attacks self.asset = null; // Set up monster asset self.init = function (type, col, row) { self.type = type; self.col = col; self.row = row; self.targetCol = col; self.targetRow = row; var assetId = type; self.asset = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5, width: MAZE_CELL_SIZE * 0.8, height: MAZE_CELL_SIZE * 0.8 }); self.x = col * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; self.y = row * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; }; // Find path to player using BFS self.findPathToPlayer = function (playerCol, playerRow) { // Defensive: check bounds if (playerCol < 0 || playerCol >= MAZE_COLS || playerRow < 0 || playerRow >= MAZE_ROWS) return null; if (maze[playerRow][playerCol] === 1) return null; var queue = []; var visited = []; for (var y = 0; y < MAZE_ROWS; y++) { visited[y] = []; for (var x = 0; x < MAZE_COLS; x++) { visited[y][x] = false; } } var prev = []; for (var y = 0; y < MAZE_ROWS; y++) { prev[y] = []; for (var x = 0; x < MAZE_COLS; x++) { prev[y][x] = null; } } queue.push({ col: self.col, row: self.row }); visited[self.row][self.col] = true; var found = false; while (queue.length > 0) { var curr = queue.shift(); if (curr.col === playerCol && curr.row === playerRow) { found = true; break; } var dirs = [{ dc: 0, dr: -1 }, // up { dc: 0, dr: 1 }, // down { dc: -1, dr: 0 }, // left { dc: 1, dr: 0 } // right ]; for (var d = 0; d < dirs.length; d++) { var nc = curr.col + dirs[d].dc; var nr = curr.row + dirs[d].dr; if (nc >= 0 && nc < MAZE_COLS && nr >= 0 && nr < MAZE_ROWS && !visited[nr][nc] && maze[nr][nc] !== 1 && maze[nr][nc] !== 4) { queue.push({ col: nc, row: nr }); visited[nr][nc] = true; prev[nr][nc] = { col: curr.col, row: curr.row }; } } } if (!found) return null; // Reconstruct path var path = []; var currCol = playerCol, currRow = playerRow; while (!(currCol === self.col && currRow === self.row)) { path.unshift({ col: currCol, row: currRow }); var p = prev[currRow][currCol]; currCol = p.col; currRow = p.row; } return path; }; // Monster update: move toward player, attack if adjacent self.update = function () { // Track last position for event logic self.lastCol = self.col; self.lastRow = self.row; // Only recalc path every 15 frames for performance if (LK.ticks % 15 === 0 || !self.path || self.path.length === 0) { self.path = self.findPathToPlayer(charCol, charRow); self.pathStepIndex = 0; } // If adjacent to player, attack var dx = Math.abs(self.col - charCol); var dy = Math.abs(self.row - charRow); if (dx + dy === 1) { // Attack cooldown if (self.attackCooldown <= 0) { // Show attack effect var effect = LK.getAsset('attackEffect', { anchorX: 0.5, anchorY: 0.5, x: charNode.x, y: charNode.y, width: MAZE_CELL_SIZE * 0.7, height: MAZE_CELL_SIZE * 0.7 }); effect.alpha = 1; game.addChild(effect); // Defensive: ensure effect is defined and tween is a function if (effect && typeof tween === "function") { var tweenObj = tween(effect); if (tweenObj && typeof tweenObj.to === "function") { tweenObj.to({ alpha: 0 }, 400).onComplete(function () { effect.destroy(); }); } } else if (effect) { // fallback: just destroy after a timeout if tween is not available LK.setTimeout(function () { effect.destroy(); }, 400); } // Flash screen red and show game over LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); self.attackCooldown = self.attackDelay; } } else if (self.path && self.path.length > 0 && self.pathStepIndex < self.path.length) { // Move toward next cell in path var next = self.path[self.pathStepIndex]; var targetX = next.col * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; var targetY = next.row * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; var ddx = targetX - self.x; var ddy = targetY - self.y; var dist = Math.sqrt(ddx * ddx + ddy * ddy); if (dist > 2) { var step = Math.min(self.moveSpeed, dist); self.x += ddx / dist * step; self.y += ddy / dist * step; } else { // Snap to cell self.x = targetX; self.y = targetY; self.col = next.col; self.row = next.row; self.pathStepIndex++; } } if (self.attackCooldown > 0) self.attackCooldown--; }; return self; }); /**** * Initialize Game ****/ // No classes needed for maze logic var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // Game constants var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; // Maze configuration // 0 = empty, 1 = wall, 2 = start, 3 = goal, 4 = door (closed) var MAZE_CELL_SIZE = 128; var MAZE_COLS = 16; var MAZE_ROWS = 21; // Example maze: outer walls, a few inner walls, start at (1,1), goal at (14,19) var maze = []; for (var y = 0; y < MAZE_ROWS; y++) { maze[y] = []; for (var x = 0; x < MAZE_COLS; x++) { if (y === 0 || y === MAZE_ROWS - 1 || x === 0 || x === MAZE_COLS - 1) { maze[y][x] = 1; // border wall } else { maze[y][x] = 0; // empty } } } // Add some doors (4 = closed door) at interesting locations maze[7][8] = 4; maze[12][5] = 4; maze[16][10] = 4; maze[5][11] = 4; // Make the maze easier: fewer inner walls and dead ends for (var i = 4; i < 12; i++) { maze[7][i] = 1; maze[12][i] = 1; } // Remove some vertical walls and dead ends for easier navigation for (var i = 4; i < 17; i++) { if (i !== 10) maze[i][4] = 1; } for (var i = 7; i < 11; i++) { maze[9][i] = 1; } // Remove some isolated wall blocks to open up the maze maze[5][2] = 1; maze[14][2] = 1; maze[2][13] = 1; maze[14][13] = 1; maze[1][1] = 2; // start maze[19][14] = 3; // goal // Score display var scoreTxt = new Text2('0', { size: 120, fill: 0xFFF700 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Draw maze walls and monsters var wallNodes = []; var monsterNodes = []; // Place monsters at specific hard maze locations for challenge var monsterSpawns = [{ type: 'skeleton', col: 5, row: 5 }, { type: 'goldenSkeleton', col: 7, row: 15 }, { type: 'zombie', col: 10, row: 10 }, { type: 'zombie', col: 12, row: 4 }, { type: 'zombie', col: 3, row: 17 }, { type: 'zombieSkeleton', col: 13, row: 8 }, { type: 'zombieSkeleton', col: 2, row: 14 }, { type: 'zombieSkeleton', col: 11, row: 18 }]; // Add asset for zombieSkeleton if not present for (var y = 0; y < MAZE_ROWS; y++) { for (var x = 0; x < MAZE_COLS; x++) { if (maze[y][x] === 1) { var wall = LK.getAsset('base', { anchorX: 0.5, anchorY: 0.5, x: x * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, y: y * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, width: MAZE_CELL_SIZE, height: MAZE_CELL_SIZE }); wallNodes.push(wall); game.addChild(wall); } // Render doors as special clickable assets if (maze[y][x] === 4) { // Use a different color for doors (yellowish) var door = LK.getAsset('base', { anchorX: 0.5, anchorY: 0.5, x: x * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, y: y * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, width: MAZE_CELL_SIZE, height: MAZE_CELL_SIZE, tint: 0xFFD700 // gold/yellow }); door._mazeCol = x; door._mazeRow = y; // Make door clickable: open on tap door.down = function (lx, ly, obj) { // Defensive: check if still a door var col = this._mazeCol; var row = this._mazeRow; if (maze[row][col] === 4) { // Open the door: set to empty maze[row][col] = 0; // Remove the door node this.destroy(); } }; wallNodes.push(door); game.addChild(door); } if (maze[y][x] === 3) { // Goal marker var goalNode = LK.getAsset('skeleton', { anchorX: 0.5, anchorY: 0.5, x: x * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, y: y * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, width: MAZE_CELL_SIZE, height: MAZE_CELL_SIZE }); game.addChild(goalNode); } // Place monsters at their spawn locations for (var mi = 0; mi < monsterSpawns.length; mi++) { var m = monsterSpawns[mi]; if (m.col === x && m.row === y) { var monster = new Monster(); monster.init(m.type, x, y); monsterNodes.push(monster); game.addChild(monster); } } } } // Find start position var charCol = 1, charRow = 1; for (var y = 0; y < MAZE_ROWS; y++) { for (var x = 0; x < MAZE_COLS; x++) { if (maze[y][x] === 2) { charCol = x; charRow = y; } } } // Create player character node and add to game var charNode = LK.getAsset('Player', { anchorX: 0.5, anchorY: 0.5, x: charCol * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, y: charRow * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2, width: MAZE_CELL_SIZE * 0.8, height: MAZE_CELL_SIZE * 0.8 }); game.addChild(charNode); // Movement state var moveTargetCol = charCol; var moveTargetRow = charRow; var isMoving = false; var moveSpeed = 16; // px per frame // Touch/drag movement: tap or drag to adjacent cell function getCellFromPos(x, y) { var col = Math.floor(x / MAZE_CELL_SIZE); var row = Math.floor(y / MAZE_CELL_SIZE); return { col: col, row: row }; } // Simple BFS pathfinding to allow tap-to-move to any reachable cell function findPath(startCol, startRow, endCol, endRow) { // Defensive: check bounds if (endCol < 0 || endCol >= MAZE_COLS || endRow < 0 || endRow >= MAZE_ROWS) return null; if (maze[endRow][endCol] === 1) return null; var queue = []; var visited = []; for (var y = 0; y < MAZE_ROWS; y++) { visited[y] = []; for (var x = 0; x < MAZE_COLS; x++) { visited[y][x] = false; } } var prev = []; for (var y = 0; y < MAZE_ROWS; y++) { prev[y] = []; for (var x = 0; x < MAZE_COLS; x++) { prev[y][x] = null; } } queue.push({ col: startCol, row: startRow }); visited[startRow][startCol] = true; var found = false; while (queue.length > 0) { var curr = queue.shift(); if (curr.col === endCol && curr.row === endRow) { found = true; break; } var dirs = [{ dc: 0, dr: -1 }, // up { dc: 0, dr: 1 }, // down { dc: -1, dr: 0 }, // left { dc: 1, dr: 0 } // right ]; for (var d = 0; d < dirs.length; d++) { var nc = curr.col + dirs[d].dc; var nr = curr.row + dirs[d].dr; if (nc >= 0 && nc < MAZE_COLS && nr >= 0 && nr < MAZE_ROWS && !visited[nr][nc] && maze[nr][nc] !== 1 && maze[nr][nc] !== 4) { queue.push({ col: nc, row: nr }); visited[nr][nc] = true; prev[nr][nc] = { col: curr.col, row: curr.row }; } } } if (!found) return null; // Reconstruct path var path = []; var currCol = endCol, currRow = endRow; while (!(currCol === startCol && currRow === startRow)) { path.unshift({ col: currCol, row: currRow }); var p = prev[currRow][currCol]; currCol = p.col; currRow = p.row; } return path; } var pathToFollow = null; var pathStepIndex = 0; game.down = function (x, y, obj) { // Prevent new move if already moving if (isMoving) return; var cell = getCellFromPos(x, y); // Defensive: check bounds if (cell.col < 0 || cell.col >= MAZE_COLS || cell.row < 0 || cell.row >= MAZE_ROWS) return; // Don't move if already at that cell if (cell.col === charCol && cell.row === charRow) return; // Find path var path = findPath(charCol, charRow, cell.col, cell.row); if (path && path.length > 0) { pathToFollow = path; pathStepIndex = 0; moveTargetCol = pathToFollow[0].col; moveTargetRow = pathToFollow[0].row; isMoving = true; } }; game.move = function (x, y, obj) { // Only allow drag-move if not already moving if (!isMoving) { game.down(x, y, obj); } }; game.up = function (x, y, obj) { // No-op }; game.update = function () { // Move character toward target cell var targetX = moveTargetCol * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; var targetY = moveTargetRow * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; var dx = targetX - charNode.x; var dy = targetY - charNode.y; var dist = Math.sqrt(dx * dx + dy * dy); if (isMoving && dist > 2) { var step = Math.min(moveSpeed, dist); charNode.x += dx / dist * step; charNode.y += dy / dist * step; } else if (isMoving) { // Snap to cell charNode.x = targetX; charNode.y = targetY; charCol = moveTargetCol; charRow = moveTargetRow; // If following a path, advance to next step if (typeof pathToFollow !== "undefined" && pathToFollow && pathStepIndex < pathToFollow.length - 1) { pathStepIndex++; moveTargetCol = pathToFollow[pathStepIndex].col; moveTargetRow = pathToFollow[pathStepIndex].row; // Remain isMoving = true } else { isMoving = false; pathToFollow = null; pathStepIndex = 0; // Check for goal if (maze[charRow][charCol] === 3) { LK.effects.flashScreen(0x00ff00, 800); LK.showYouWin(); } } } // Update all monsters for (var i = 0; i < monsterNodes.length; i++) { if (monsterNodes[i] && typeof monsterNodes[i].update === "function") { monsterNodes[i].update(); } } // Show current cell in score text (for debugging movement) scoreTxt.setText("Cell: " + charCol + "," + charRow); };
===================================================================
--- original.js
+++ change.js
@@ -233,45 +233,25 @@
maze[7][8] = 4;
maze[12][5] = 4;
maze[16][10] = 4;
maze[5][11] = 4;
-// Add a much harder maze pattern with more inner walls and dead ends
-for (var i = 2; i < 14; i++) {
- maze[3][i] = 1;
+// Make the maze easier: fewer inner walls and dead ends
+for (var i = 4; i < 12; i++) {
maze[7][i] = 1;
maze[12][i] = 1;
- maze[16][i] = 1;
}
-// Add vertical walls and dead ends
-for (var i = 2; i < 19; i++) {
- if (i !== 7 && i !== 12) maze[i][4] = 1;
- if (i !== 3 && i !== 16) maze[i][11] = 1;
+// Remove some vertical walls and dead ends for easier navigation
+for (var i = 4; i < 17; i++) {
+ if (i !== 10) maze[i][4] = 1;
}
-for (var i = 5; i < 11; i++) {
+for (var i = 7; i < 11; i++) {
maze[9][i] = 1;
}
-for (var i = 6; i < 15; i++) {
- if (i !== 10) maze[15][i] = 1;
-}
-for (var i = 2; i < 8; i++) {
- maze[i][7] = 1;
-}
-for (var i = 13; i < 19; i++) {
- maze[i][8] = 1;
-}
+// Remove some isolated wall blocks to open up the maze
maze[5][2] = 1;
-maze[6][2] = 1;
-maze[8][2] = 1;
-maze[10][2] = 1;
maze[14][2] = 1;
-maze[18][2] = 1;
maze[2][13] = 1;
-maze[4][13] = 1;
-maze[6][13] = 1;
-maze[8][13] = 1;
-maze[10][13] = 1;
maze[14][13] = 1;
-maze[18][13] = 1;
maze[1][1] = 2; // start
maze[19][14] = 3; // goal
// Score display
var scoreTxt = new Text2('0', {
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Monster Mash: Undead Defense" and with the description "Defend your base from zombies, skeletons, and their golden counterparts by tapping or dragging to attack. Survive waves and score points!". No text on banner!
Zombie with long red eyes. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A zombie with long eyes but everything is golden. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A golden terrifying skeleton. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A zombie fixed with a skeleton. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Ghost. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Heart. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Monster with big hands and ginger hair. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat