User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(effect).to({' Line Number: 172
User prompt
Make the zombies be able to kill you and then add a jump scare.
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(effect).to({' Line Number: 170
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(effect).to({' Line Number: 169
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(effect, {' Line Number: 169
User prompt
Make a golden zombie segment
User prompt
Make sure the monsters can move around and also make them follow you and try and kill you.
User prompt
Add the skeleton, and the golden zombie, and the golden skeleton.
User prompt
Make the maze a lot harder
User prompt
Add the monsters back in
User prompt
i can't move can you like do it where like you when you tap on the place it moves to that place
User prompt
Make a way to move, please!
User prompt
Make it a maze instead of that. It's a big maze and the character moves through the maze and cannot pass through walls.
Code edit (1 edits merged)
Please save this source code
User prompt
Monster Mash: Undead Defense
User prompt
Monsters are the zombie, the skeleton, the golden zombie, the golden skeleton.
Initial prompt
It was like the first game but with a higher difficulty and also more monsters.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * 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 // Each cell is 128x128 px, so 16x21 grid fits in 2048x2688 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 inner walls (example pattern) for (var i = 2; i < 14; i++) { maze[3][i] = 1; maze[7][i] = 1; maze[12][i] = 1; maze[16][i] = 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 var wallNodes = []; 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); } if (maze[y][x] === 3) { // Goal marker var goalNode = LK.getAsset('goldenZombie', { 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); } } } // Character var charNode = LK.getAsset('zombie', { anchorX: 0.5, anchorY: 0.5, width: MAZE_CELL_SIZE * 0.8, height: MAZE_CELL_SIZE * 0.8 }); game.addChild(charNode); // 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; } } } charNode.x = charCol * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; charNode.y = charRow * MAZE_CELL_SIZE + MAZE_CELL_SIZE / 2; // 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) { 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(); } } } // Show current cell in score text (for debugging movement) scoreTxt.setText("Cell: " + charCol + "," + charRow); };
===================================================================
--- original.js
+++ change.js
@@ -115,24 +115,110 @@
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) {
+ 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;
- // Only allow move to adjacent cell (no diagonals)
- var dx = cell.col - charCol;
- var dy = cell.row - charRow;
- if (Math.abs(dx) === 1 && dy === 0 || Math.abs(dy) === 1 && dx === 0) {
- // Check wall
- if (maze[cell.row] && maze[cell.row][cell.col] !== 1) {
- moveTargetCol = cell.col;
- moveTargetRow = cell.row;
- isMoving = true;
- }
+ // 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
@@ -159,13 +245,23 @@
charNode.x = targetX;
charNode.y = targetY;
charCol = moveTargetCol;
charRow = moveTargetRow;
- isMoving = false;
- // Check for goal
- if (maze[charRow][charCol] === 3) {
- LK.effects.flashScreen(0x00ff00, 800);
- LK.showYouWin();
+ // 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();
+ }
}
}
// Show current cell in score text (for debugging movement)
scoreTxt.setText("Cell: " + charCol + "," + charRow);
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