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
User prompt
Reduce player size little bit
User prompt
Reduce its size to fit between walls
User prompt
make the player smaller
User prompt
Please fix the bug: 'ReferenceError: Wall is not defined' in or related to this line: 'if (game.children[i] instanceof Wall && self.intersects(game.children[i])) {' Line Number: 35
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'update')' in or related to this line: 'player.update = function () {' Line Number: 116
User prompt
Make player assets to fit in the maze. make collision between player and walls
User prompt
Make surrounded lines for the maze by filling the lines of the 4 sides with walls
User prompt
Make the maze with same size of the screen
User prompt
Fix the game not loading
/**** * 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: 50, height: 50 }); 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 ****/ // Function to generate a random maze var blockSize; 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() { 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 || i === mazeWidth - 1 || j === 0 || 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.7 && !(i % 2 === 0 && j % 2 === 0)) { // Adjusted randomness for different maze pattern // Clear paths in the maze by not creating a wall at every second column and every second row 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; // Create an exit in the maze var exit = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); exit.width = blockSize; exit.height = blockSize; exit.x = game.width - blockSize / 2; exit.y = blockSize / 2; game.addChild(exit); // 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
@@ -51,8 +51,10 @@
/****
* Game Code
****/
+// Function to generate a random maze
+var blockSize;
var background = LK.getAsset('Background1', {
anchorX: 0.5,
anchorY: 0.5
});
@@ -62,9 +64,9 @@
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
+ 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++) {