User prompt
Make the exit on the right top corner befor walls
User prompt
Add the exit asset to the maze make it shown in the screen, with same size of small wall asset
User prompt
Make the player position the left bottom corner inside maze
User prompt
Make the player have same size of the small walls without changing anything of the maze or its shape
User prompt
Add exit to the maze
User prompt
Change the exit position to be right upper corner before maze walls
User prompt
Add the exit asset to the game
User prompt
Analyse the game!
User prompt
Change playre position to the right corner
User prompt
repear game player is bigger then spaces in the maze
User prompt
fix it
User prompt
Add the exit to the maze game make it and player with same same size of wall asset.
User prompt
Please fix the bug: 'blockSize is not defined' in or related to this line: 'exit.width = blockSize;' Line Number: 114
User prompt
Make more cleared paths and make an exit
User prompt
Don't make it moving automatic make it on the lower left corner before walls of maze
User prompt
fix player can be moving between any walls of the maze
User prompt
Don't change the maze with changing of the player or when i resize it.
Code edit (1 edits merged)
Please save this source code
User prompt
Don't let player fit to the maze
User prompt
resize the player but not the maze let this maze.
User prompt
Make some cleared paths for player to move on all the maze
User prompt
Make maze difficult by adding some walls
User prompt
don't follow only by click to drag it
User prompt
Make player follow mouse cursor on the screen
User prompt
Put it on the left bottom corner before walls of maze
/**** * Classes ****/ // Create a Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, width: 20, height: 20 }); self.speed = 5; self.update = function () { if (self.x < 0) { self.x = 0; } if (self.y < 0) { self.y = 0; } if (self.x > game.width) { self.x = game.width; } if (self.y > game.height) { self.y = game.height; } for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall && self.intersects(game.children[i])) { self.speed = 0; } } }; }); //<Assets used in the game will automatically appear here> // Create a Wall class var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ // Function to generate a random maze var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = LK.getAsset('Background1', { anchorX: 0.5, anchorY: 0.5 }); background.width = game.width; background.height = game.height; background.x = game.width / 2; background.y = game.height / 2; game.addChildAt(background, 0); // Function to generate a random maze function generateMaze() { var blockSize = Math.floor(Math.random() * 30) + 20; // Random block size between 20 and 50 var mazeWidth = Math.floor(game.width / blockSize); var mazeHeight = Math.floor(game.height / blockSize); for (var i = 0; i < mazeWidth; i++) { for (var j = 0; j < mazeHeight; j++) { if (i === 0) { var wall = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); wall.width = blockSize; wall.height = blockSize; wall.x = i * blockSize + blockSize / 2; wall.y = j * blockSize + blockSize / 2; game.addChild(wall); } else if (i === mazeWidth - 1) { var wall = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); wall.width = blockSize; wall.height = blockSize; wall.x = i * blockSize + blockSize / 2; wall.y = j * blockSize + blockSize / 2; game.addChild(wall); } else if (j === 0) { var wall = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); wall.width = blockSize; wall.height = blockSize; wall.x = i * blockSize + blockSize / 2; wall.y = j * blockSize + blockSize / 2; game.addChild(wall); } else if (j === mazeHeight - 1) { var wall = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); wall.width = blockSize; wall.height = blockSize; wall.x = i * blockSize + blockSize / 2; wall.y = j * blockSize + blockSize / 2; game.addChild(wall); } else if (Math.random() > 0.8) { // Adjusted randomness for different maze pattern var wall = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); wall.width = blockSize; wall.height = blockSize; wall.x = i * blockSize + blockSize / 2; wall.y = j * blockSize + blockSize / 2; game.addChild(wall); } } } } generateMaze(); var player = game.addChild(new Player()); player.x = 50; player.y = game.height - 50; // Add mouse down event to make player follow the cursor only when clicked and dragged var dragNode = null; game.down = function (x, y, obj) { dragNode = player; }; game.move = function (x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; } }; game.up = function (x, y, obj) { dragNode = null; };
===================================================================
--- original.js
+++ change.js
@@ -126,9 +126,18 @@
generateMaze();
var player = game.addChild(new Player());
player.x = 50;
player.y = game.height - 50;
-// Add mouse move event to make player follow the cursor
+// Add mouse down event to make player follow the cursor only when clicked and dragged
+var dragNode = null;
+game.down = function (x, y, obj) {
+ dragNode = player;
+};
game.move = function (x, y, obj) {
- player.x = x;
- player.y = y;
+ if (dragNode) {
+ dragNode.x = x;
+ dragNode.y = y;
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
};
\ No newline at end of file