User prompt
Make collision for the new walls
User prompt
Randomize the shapes
User prompt
Make the screen the ground for all objects and all can be touched
User prompt
add collision to player
User prompt
change the shape of maze walls
User prompt
do different shapes
User prompt
Add same walls of the removed maze
User prompt
Let the walls maze and the maze just remove the random option to not randomize the maze in each load of the game.
User prompt
Remove random obstacles function let this maze for the game now.
User prompt
Make player move by click direction and follow that direction
User prompt
Add more
User prompt
Make the obstacle walls can be touched
User prompt
random the shapes of walls for the maze inside all the space
User prompt
Fill the maze by abstacles
User prompt
Make it inside maze corner not screen corner
User prompt
Hold position player on the left bottom walls of maze corner
User prompt
Don't let player pass the maze walls
User prompt
1-Fill the inside space of maze walls with obstacles. 2-Make exit and player inside corner of walls
User prompt
Make many obstacles
User prompt
Make a static maze with different obstacles if player touch any obstacles do game over. Make the player in left bottom corner of the maze and exit on the top right of it
User prompt
Don't change th maze shape each time randoly let only one maze
User prompt
Make the player follow cursor exact same time not far from it
User prompt
If player touch exit asset in the maze do game over
User prompt
Don't teleport player to cursor and let it follow it only if hold on it
User prompt
Make collision between wall asset and player and can't pass through it if moving on the screen. can only move in the spaces.
/**** * Classes ****/ // Create an Exit class var Exit = Container.expand(function () { var self = Container.call(this); var exitGraphics = self.attachAsset('Exit', { anchorX: 1, anchorY: 1, width: blockSize * 2, height: blockSize * 2 }); }); // 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: blockSize, height: blockSize }); 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])) { LK.showGameOver(); } } }; }); //<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 static maze var blockSize = 50; 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 generateMaze() { 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 || i === 3 && j > 2 && j < 8 || i === 6 && j > 4 && j < 10 || i > 6 && i < 10 && j === 6 || i === 8 && j > 2 && j < 8 || i === 10 && j > 4 && j < 10 || i > 10 && i < 14 && j === 8 || i === 5 && j === 5 || i === 7 && j === 7 || i === 9 && j === 9 || i === 11 && j === 11 || i === 13 && j === 13 || i === 2 && j === 2 || i === 4 && j === 4 || i === 6 && j === 6 || i === 8 && j === 8 || i === 10 && j === 10 || i === 12 && j === 12 || i === 14 && j === 14) { 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 = blockSize * 1.5; player.y = game.height - blockSize * 1.5; // Create an exit in the maze var exit = game.addChild(new Exit()); exit.width = blockSize; exit.height = blockSize; exit.x = game.width - blockSize * 2.5; exit.y = blockSize * 2.5; // 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.width / 2; dragNode.y = y - dragNode.height / 2; if (player.intersects(exit)) { LK.showGameOver(); } } }; game.up = function (x, y, obj) { dragNode = null; };
===================================================================
--- original.js
+++ change.js
@@ -77,9 +77,9 @@
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 || i === 3 && j > 2 && j < 8 || i === 6 && j > 4 && j < 10 || i > 6 && i < 10 && j === 6 || i === 8 && j > 2 && j < 8 || i === 10 && j > 4 && j < 10 || i > 10 && i < 14 && j === 8 || i === 5 && j === 5 || i === 7 && j === 7 || i === 9 && j === 9 || i === 11 && j === 11 || i === 13 && j === 13) {
+ if (i === 0 || i === mazeWidth - 1 || j === 0 || j === mazeHeight - 1 || i === 3 && j > 2 && j < 8 || i === 6 && j > 4 && j < 10 || i > 6 && i < 10 && j === 6 || i === 8 && j > 2 && j < 8 || i === 10 && j > 4 && j < 10 || i > 10 && i < 14 && j === 8 || i === 5 && j === 5 || i === 7 && j === 7 || i === 9 && j === 9 || i === 11 && j === 11 || i === 13 && j === 13 || i === 2 && j === 2 || i === 4 && j === 4 || i === 6 && j === 6 || i === 8 && j === 8 || i === 10 && j === 10 || i === 12 && j === 12 || i === 14 && j === 14) {
var wall = LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
});