User prompt
If make the maze stop if the asset image of wall touched the player face to face
User prompt
Slow the movment of spawning
User prompt
Continu th espaning to the bottom of the screen and pass it
User prompt
Make the line passable to the cube
User prompt
Make it pass the player only by space between walls. make it pass the screen bottom
User prompt
Make the maze respaning inside the screen only
User prompt
Make the player and walls on the same range to get touched
User prompt
Move the moving maze a little bit to the right
User prompt
If any wall assets of the walls of the moving maze touch the player square push it to the bottom
User prompt
Fix the dodging of walls
User prompt
Fix the game
User prompt
Make the wall asset can puch the player
User prompt
Start respawning the random walls of maze when game loaded
User prompt
Let player follow the corsor exact same time
User prompt
Make it move with the cursor not far from it
User prompt
Player can't touch the walls!
User prompt
Make it move right and left to evade walls
User prompt
Resize the player with the same size of wall asset. Make collison if touched by any wall stop the maze
User prompt
Make the maze respawn as the same tall of the top side of it but not with taller walls
User prompt
Make the maze to the right a bit
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: 82
User prompt
Make many walls like moving maze from the top
User prompt
Start respawn random walls from top to bottom.player must evade it
User prompt
Please fix the bug: 'blockSize is not defined' in or related to this line: 'var playerGraphics = self.attachAsset('player', {' Line Number: 26
User prompt
Add player to the bottom middl of scren
/**** * Classes ****/ // Create an Exit class var Exit = Container.expand(function () { var self = Container.call(this); var exitGraphics = self.attachAsset('Exit', { anchorX: 0.5, anchorY: 0.5, width: blockSize * 1.5, height: blockSize * 1.5 }); }); //<Assets used in the game will automatically appear here> // Create a Maze class var Maze = Container.expand(function () { var self = Container.call(this); self.speed = 5; self.update = function () { if (self.y + self.height < game.height) { self.y += self.speed; } }; // Generate a random maze with spaces for (var i = 0; i < game.width / blockSize; i++) { if (Math.random() < 0.3) { // 30% chance to spawn a wall block var wall = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5, x: i * blockSize, y: 0, width: blockSize, height: blockSize }); } else { // 70% chance to spawn a space block var space = self.attachAsset('line', { anchorX: 0.5, anchorY: 0.5, x: i * blockSize, y: 0, width: blockSize, height: blockSize }); } } }); // 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 = 8; self.vx = 0; self.vy = 0; self.update = function () { var oldX = self.x; var oldY = self.y; self.x += self.vx; self.y += self.vy; 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 = 0; } // Check for collision with wall and space for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall && self.intersects(game.children[i])) { // Add a push effect to the player when it collides with a wall self.x = oldX; self.y = game.children[i].y - self.height / 2; break; } else if (game.children[i] instanceof Space && self.intersects(game.children[i])) { // Allow the player to pass through spaces continue; } } // Add Maze to the game if (LK.ticks % 60 == 0) { var maze = new Maze(); game.addChild(maze); } }; }); // Create a Space class var Space = Container.expand(function () { var self = Container.call(this); var spaceGraphics = self.attachAsset('line', { anchorX: 0.5, anchorY: 0.5, width: blockSize, height: blockSize }); }); // 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, width: blockSize, height: blockSize }); }); /**** * Initialize Game ****/ // Check for collision with wall // Function to generate a random maze var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Add move event to the game game.move = function (x, y, obj) { // Move the player to the x position of the touch or mouse event player.x = x - player.width / 2; }; var blockSize = 100; // Add player to the bottom middle of the screen var player = game.addChild(new Player()); player.x = game.width / 2; player.y = game.height - player.height / 2; ; game.down = function (x, y, obj) { // Start moving the player when touch or mouse down game.move(x, y, obj); }; game.up = function (x, y, obj) { // Stop moving the player when touch or mouse up player.vx = 0; };
===================================================================
--- original.js
+++ change.js
@@ -20,9 +20,9 @@
if (self.y + self.height < game.height) {
self.y += self.speed;
}
};
- // Generate a random maze
+ // Generate a random maze with spaces
for (var i = 0; i < game.width / blockSize; i++) {
if (Math.random() < 0.3) {
// 30% chance to spawn a wall block
var wall = self.attachAsset('wall', {
@@ -32,8 +32,18 @@
y: 0,
width: blockSize,
height: blockSize
});
+ } else {
+ // 70% chance to spawn a space block
+ var space = self.attachAsset('line', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: i * blockSize,
+ y: 0,
+ width: blockSize,
+ height: blockSize
+ });
}
}
});
// Create a Player class
@@ -64,15 +74,18 @@
}
if (self.y > game.height) {
self.y = 0;
}
- // Check for collision with wall
+ // Check for collision with wall and space
for (var i = 0; i < game.children.length; i++) {
if (game.children[i] instanceof Wall && self.intersects(game.children[i])) {
// Add a push effect to the player when it collides with a wall
self.x = oldX;
self.y = game.children[i].y - self.height / 2;
break;
+ } else if (game.children[i] instanceof Space && self.intersects(game.children[i])) {
+ // Allow the player to pass through spaces
+ continue;
}
}
// Add Maze to the game
if (LK.ticks % 60 == 0) {
@@ -80,8 +93,18 @@
game.addChild(maze);
}
};
});
+// Create a Space class
+var Space = Container.expand(function () {
+ var self = Container.call(this);
+ var spaceGraphics = self.attachAsset('line', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: blockSize,
+ height: blockSize
+ });
+});
// Create a Wall class
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {