User prompt
not moving on top respawn it to go down
User prompt
Make horizontal shapes spawning from the top as the vertical
User prompt
make both shapes from top only
User prompt
Please fix the bug: 'Timeout.tick error: window[wallType] is not a constructor' in or related to this line: 'var wall = new window[wallType](); // Create wall instance based on type' Line Number: 180
User prompt
Make random vertical and horizontal spawning
User prompt
Make it thin and taller
User prompt
Make some taller vertical and horizontal
User prompt
Add wall1 to level 1 respawning randomly from the top
User prompt
Remove all walls from game
User prompt
Another wall respawning with wall2!
User prompt
Remove wall1 from the screen if level 2 start and replace it by wall2
User prompt
Check for bugs
User prompt
Replace wall1 by wall2 in level 2
User prompt
Remove wall 1 from level 2
User prompt
Remove mazewalls from level 2
User prompt
Respawn wall2 from right side
User prompt
wall1 still respawning in level2!
User prompt
Fix th egame in level 2
User prompt
Stop respawning from left and right in level 2
User prompt
Add wall2 to level 2 from top random shapes as level 1
User prompt
Remove all walls from level 2
User prompt
If level 2 start stop respawning of level 1 objects
User prompt
Set wall2 respawning from the top randomly in level 2
User prompt
Remove the respawning in level 2
User prompt
Remove wall1 from level 2
/**** * Classes ****/ var BottomWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y -= 5; if (self.y < 0) { self.destroy(); } }; }); var HorizontalWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5, scaleX: 2 // Increase width to make it wider }); self.update = function () { self.x += 5; if (self.x > 2048) { self.x = 0; } else if (self.x < 0) { self.x = 2048; } }; }); var LeftWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x -= 5; if (self.x < 0) { self.destroy(); } }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { for (var i = 0; i < mazeWalls.length; i++) { if (self.intersects(mazeWalls[i]) && mazeWalls[i].parent) { var dx = self.x - mazeWalls[i].x; var dy = self.y - mazeWalls[i].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < self.width / 2 + mazeWalls[i].width / 2) { LK.showGameOver(); } } } }; }); var RightWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x += 5; if (self.x > 2048) { self.destroy(); } }; }); var TopWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 5; if (self.y > 2732) { self.destroy(); } }; }); var VerticalWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5, scaleY: 2 // Increase height to make it taller }); self.update = function () { self.y += 5; if (self.y > 2732) { self.y = 0; } else if (self.y < 0) { self.y = 2732; } }; }); var Wall1 = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, // Make it thinner scaleY: 2 // Make it taller }); self.update = function () { self.y += 5; if (self.y > 2732) { self.destroy(); } }; }); /**** * Initialize Game ****/ // Removed maze regeneration and player reinitialization // Removed player movement and click event listener related to the maze // Function to generate a random maze var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background1 = LK.getAsset('Background1', { anchorX: 0.5, anchorY: 0.5 }); background1.scaleX = 2048 / background1.width; background1.scaleY = 2732 / background1.height; background1.x = 2048 / 2; background1.y = 2732 / 2; game.addChild(background1); if (level == 2) { var background2 = LK.getAsset('Background2', { anchorX: 0.5, anchorY: 0.5 }); background2.scaleX = 2048 / background2.width; background2.scaleY = 2732 / background2.height; background2.x = 2048 / 2; background2.y = 2732 / 2; game.addChild(background2); } // Update game loop to move maze walls // Add event listener for player movement game.move = function (x, y, obj) { player.x = Math.max(player.width / 2, Math.min(2048 - player.width / 2, x)); player.y = Math.max(player.height / 2, Math.min(2732 - player.height / 2, y)); }; var mazeWalls = []; moveMazeWalls(); // Removed duplicate interval creation for generateMazeWall function generateMazeWall() { if (level == 1) { var wallType = Math.random() < 0.5 ? 'VerticalWall' : 'HorizontalWall'; // Randomly choose wall type var wall = new window[wallType](); // Create wall instance based on type if (wallType === 'VerticalWall') { wall.x = Math.random() * 2048; // Random horizontal position wall.y = Math.random() < 0.5 ? 0 : 2732; // Randomly spawn from top or bottom } else { wall.x = Math.random() < 0.5 ? 0 : 2048; // Randomly spawn from left or right wall.y = Math.random() * 2732; // Random vertical position } mazeWalls.push(wall); game.addChild(wall); } } function moveMazeWalls() { // Removed wall update logic } LK.setInterval(generateMazeWall, 500); // Update timer every second LK.setInterval(function () { timer--; var seconds = timer; timerText.setText('Time: ' + (seconds < 10 ? '0' : '') + seconds); // If time is up, go to next level if (timer <= 0) { level++; if (level == 2) { timer = 40; // 40 seconds for level 2 } else if (level == 3) { timer = 60; // 60 seconds for level 3 } levelText.setText('Level: ' + level); } // Remove lag when reach 5 sec // Removed premature interval clearing logic }, 1000); var player = new Player(); game.addChild(player); player.x = 2048 / 2; player.y = 2732 / 2; // Initialize timer and level variables var timer = 10; // 10 seconds for level 1 var level = 1; // Add level text to the top right corner var levelText = new Text2('Level: 1', { size: 100, fill: 0x808080 // Grey color }); levelText.anchor.set(1, 0); // Sets anchor to the top right corner of the text. LK.gui.topRight.addChild(levelText); // Add timer text to the top left corner var timerText = new Text2('Time: 10', { size: 100, fill: 0x808080 // Grey color }); timerText.anchor.set(0, 0); // Sets anchor to the top left corner of the text. LK.gui.topLeft.addChild(timerText); ;
===================================================================
--- original.js
+++ change.js
@@ -164,11 +164,17 @@
moveMazeWalls();
// Removed duplicate interval creation for generateMazeWall
function generateMazeWall() {
if (level == 1) {
- var wall = new Wall1();
- wall.x = Math.random() * 2048;
- wall.y = 0;
+ var wallType = Math.random() < 0.5 ? 'VerticalWall' : 'HorizontalWall'; // Randomly choose wall type
+ var wall = new window[wallType](); // Create wall instance based on type
+ if (wallType === 'VerticalWall') {
+ wall.x = Math.random() * 2048; // Random horizontal position
+ wall.y = Math.random() < 0.5 ? 0 : 2732; // Randomly spawn from top or bottom
+ } else {
+ wall.x = Math.random() < 0.5 ? 0 : 2048; // Randomly spawn from left or right
+ wall.y = Math.random() * 2732; // Random vertical position
+ }
mazeWalls.push(wall);
game.addChild(wall);
}
}