User prompt
Add 2 lines in level 1
User prompt
Add 2 lines in level 1
User prompt
Make the walls small in level 1
User prompt
Make 5 lines with same vertical space and make it in the middle
User prompt
Respawn wall1 inside screen
User prompt
Increase walls in level 1 make it small
User prompt
Make the walls small in level 2
User prompt
Make large space between the respawning walls of wall 2
User prompt
Increas walls in level 2
User prompt
decrease walls in level 1
User prompt
Make 4 walls each 4 sec in level 1
User prompt
Reduce walls in level 4 let same walls but make it few only Respawn wall4 inside screen boundaries
User prompt
Make more space between 4 respawning walls in level 1
Code edit (1 edits merged)
Please save this source code
User prompt
Make more space between lines
User prompt
Respawn wall1 only in the 4 lines
Code edit (4 edits merged)
Please save this source code
User prompt
Reduce respawning walls of wall1
User prompt
center the 4 lines
Code edit (1 edits merged)
Please save this source code
User prompt
Respawn 4 walls and large distance between walls and the space 2 times as the size of the player between lines of wall1
User prompt
Reduce space between lines of wall1
User prompt
Remove 1 line let it 4 only and fixed position from the right horizontally
User prompt
Don't respawn in random positions respawn from 4 positions only.
User prompt
Make it 4 sec
/**** * Classes ****/ // Create a DodgingObject class for objects in level 10 var DodgingObject = Container.expand(function () { var self = Container.call(this); // Attach a random shape asset to represent the dodging object var dodgingGraphics = self.attachAsset('shape' + Math.floor(Math.random() * 10), { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 100 + 50, // Random width between 50 and 150 height: Math.random() * 100 + 50 // Random height between 50 and 150 }); // Set dodging object speed self.speed = 4; // This is automatically called every game tick, if the dodging object is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = 0; // Reset position to the top self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Gate class for level 1 var Gate = Container.expand(function () { var self = Container.call(this); // Attach a gate asset to represent the gate var gateGraphics = self.attachAsset('Gate', { anchorX: 0.5, anchorY: 0.5 }); // Set gate position self.x = game.width / 2; self.y = gateGraphics.height / 2; // Position the gate at the top of the screen // Add continuous rotation to the gate self.update = function () { gateGraphics.rotation += 0.05; // Rotate the gate by 0.05 radians per frame }; }); // Create a Player class var Player = Container.expand(function () { var self = Container.call(this); // Attach a shape asset to represent the player var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); // Set player speed self.speed = level >= 2 && level <= 10 ? 16 : 12; // This is automatically called every game tick, if the player is attached! self.update = function () { // Implement non-continuous movement self.moveTo = function (x, y) { var directionX = x - self.x; var directionY = y - self.y; if (Math.abs(directionX) > Math.abs(directionY)) { // Move horizontally if (directionX > 0) { self.x += self.speed; // Move right } else { self.x -= self.speed; // Move left } } else { // Move vertically if (directionY > 0) { self.y += self.speed; // Move down } else { self.y -= self.speed; // Move up } } self.x = Math.max(self.width / 2, Math.min(game.width - self.width / 2, self.x)); self.y = Math.max(self.height / 2, Math.min(game.height - self.height / 2, self.y)); }; }; }); // Create a RandomShape class for shapes spawning from top and left var RandomShape = Container.expand(function () { var self = Container.call(this); // Attach a random shape asset to represent the shape var shapeGraphics = self.attachAsset('shape' + Math.floor(Math.random() * 10), { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200, // Random width between 0 and 200 height: Math.random() * 200 // Random height between 0 and 200 }); // Set shape speed self.speed = 2; // This is automatically called every game tick, if the shape is attached! self.update = function () { // Randomly decide the direction of the shape if (Math.random() < 0.5) { self.y += self.speed; } else { self.x += self.speed; } }; }); // Create a Wall class for walls with configurable movement and dimensions var Wall = Container.expand(function (options) { var self = Container.call(this); var wallGraphics = self.attachAsset(options.assetId, { anchorX: 0.5, anchorY: 0.5, width: options.width || Math.random() * 100 + 50, height: options.height || Math.random() * 600 + 300 }); self.speed = options.speed || 4; self.update = function () { if (options.direction === 'vertical') { self.y += self.speed; if (self.y > game.height) { self.y = Math.random() * (game.height - player.height - levelText.height) + levelText.height; // Respawn below level text and above player self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } } else if (options.direction === 'horizontal') { self.x += self.speed; if (self.x > game.width) { self.x = -self.width; // Increase distance by starting left of the screen self.y = Math.random() * (game.height - gate.height - player.height - player.height) + gate.height + player.height / 2; // Avoid respawning on the side of player or gate } } }; }); var Wall10 = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall10', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 400 + 200 }); self.speed = 8; self.update = function () { self.y += self.speed; if (self.y > game.height) { self.y = 0; self.x = Math.random() * (game.width - self.width) + self.width / 2; } }; }); // Create a Wall2 class for walls in level 2 var Wall2 = Container.expand(function () { var self = Container.call(this); // Attach a wall2 asset to represent the wall var wallGraphics = self.attachAsset('wall2', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 1000 + 600 }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = -self.height; // Increase distance by starting above the screen self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Wall2Horizontal class for large horizontal walls moving from left to right in level 2 var Wall2Horizontal = Container.expand(function () { var self = Container.call(this); // Attach a wall2 asset to represent the wall var wallGraphics = self.attachAsset('wall2', { anchorX: 0.5, anchorY: 0.5, width: 400, // Reduce the width of the wall height: 75 // Reduce the height of the wall }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards if (self.x > game.width) { self.x = 0; // Reset position to the left when reaching the right edge self.y = Math.random() * (game.height - self.height) + self.height / 2 + 300; // Further increase spacing between each respawning wall } }; }); // Create a Wall2HorizontalRight class for large horizontal walls moving from right to left in level 2 var Wall2HorizontalRight = Container.expand(function () { var self = Container.call(this); // Attach a wall2 asset to represent the wall var wallGraphics = self.attachAsset('wall2', { anchorX: 0.5, anchorY: 0.5, width: 400, // Reduce the width of the wall height: 75 // Reduce the height of the wall }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards if (self.x < -self.width) { self.x = game.width; // Reset position to the right when reaching the left edge self.y = Math.random() * (game.height - self.height) + self.height / 2 + 300; // Further increase spacing between each respawning wall } }; }); // Create a Wall3 class for walls respawning from bottom to top var Wall3 = Container.expand(function () { var self = Container.call(this); // Attach a wall3 asset to represent the wall var wallGraphics = self.attachAsset('wall3', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 50 + 25, height: Math.random() * 150 + 75 // Further reduce height for bottom side vertical walls in level 3 }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y < 0) { self.y = game.height + self.height; // Increase distance by starting below the screen self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Wall3Right class for walls spawning from right to left var Wall3Right = Container.expand(function () { var self = Container.call(this); // Attach a wall3 asset to represent the wall var wallGraphics = self.attachAsset('wall3', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 600 + 400, // Increase width for larger horizontal walls on the right side in level 3 // Increase width for larger horizontal walls on the right side in level 3 height: Math.random() * 200 + 100 // Random height }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards }; }); // Create a Wall4 class for walls moving horizontally from left to right var Wall4 = Container.expand(function () { var self = Container.call(this); // Attach a wall4 asset to represent the wall var wallGraphics = self.attachAsset('wall4', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 100 // Set fixed dimensions for top respawning walls }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards if (self.x > game.width) { self.x = -self.width; // Reset position to the left self.y = Math.random() * (game.height - self.height) + self.height / 2; // Randomize vertical position } }; }); // Create a Wall4Diagonal class for walls moving diagonally from top left to bottom right var Wall4Diagonal = Container.expand(function () { var self = Container.call(this); // Attach a wall4 asset to represent the wall var wallGraphics = self.attachAsset('wall4', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 200 }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards self.y += self.speed; // Move downwards if (self.x > game.width || self.y > game.height) { self.x = 0; // Reset position to the left self.y = 0; // Reset position to the top } }; }); // Create a Wall4DiagonalBottomRight class for walls moving diagonally from bottom right to top left var Wall4DiagonalBottomRight = Container.expand(function () { var self = Container.call(this); // Attach a wall4 asset to represent the wall var wallGraphics = self.attachAsset('wall4', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 200 }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards self.y -= self.speed; // Move upwards if (self.x < 0 || self.y < 0) { self.x = game.width; // Reset position to the right self.y = game.height; // Reset position to the bottom } }; }); // Create a Wall4Horizontal class for walls spawning randomly from left and right horizontally var Wall4Horizontal = Container.expand(function () { var self = Container.call(this); // Attach a wall4 asset to represent the wall var wallGraphics = self.attachAsset('wall4', { width: Math.random() * 400 + 200 // Increase width for level 4 }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards if (self.x > game.width) { self.x = -self.width; // Reset position to the left when reaching the right edge self.y = Math.random() * (game.height - self.height) + self.height / 2; // Randomize vertical position } }; }); // Create a Wall4Vertical class for walls moving vertically from top to bottom var Wall4Vertical = Container.expand(function () { var self = Container.call(this); // Attach a wall4 asset to represent the wall var wallGraphics = self.attachAsset('wall4', { width: 100, // Set fixed width for left respawning walls height: Math.random() * 400 + 200 // Reduce height for level 4 }); // Set wall speed self.speed = 10; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = 0; // Reset position to the top when reaching the bottom edge self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position within screen boundaries } }; }); // Create a Wall5 class for walls with random shapes var Wall5 = Container.expand(function () { var self = Container.call(this); // Attach a wall5 asset to represent the wall var wallGraphics = self.attachAsset('wall5', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 100 + 50, // Random width height: Math.random() * 400 + 200 // Increase height to make walls taller }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { // Move vertically from top to bottom self.x += self.speed; // Move rightwards self.y -= self.speed; // Move upwards if (self.x > game.width || self.y < 0) { self.x = 0; // Reset position to the left self.y = game.height; // Reset position to the bottom } // Move horizontally from left to right self.x += self.speed; // Move rightwards if (self.x > game.width) { self.x = 0; // Reset position to the left when reaching the right edge self.y = Math.random() * (game.height - self.height) + self.height / 2; // Randomize vertical position } }; }); // Create a Wall5Horizontal class for walls respawning horizontally in level 5 var Wall5Horizontal = Container.expand(function () { var self = Container.call(this); // Attach a wall5 asset to represent the wall var wallGraphics = self.attachAsset('wall5', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 400 + 200, height: Math.random() * 200 + 100 }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { // Move horizontally from left to right self.x += self.speed; if (self.x > game.width) { self.x = 0; // Reset position to the left when reaching the right edge self.y = Math.random() * (game.height - self.height) + self.height / 2 + 200; // Further increase spacing between each respawning wall self.y += 50; // Add spacing between each respawning wall } }; }); // Create a Wall5Vertical class for walls respawning vertically in level 5 var Wall5Vertical = Container.expand(function () { var self = Container.call(this); // Attach a wall5 asset to represent the wall var wallGraphics = self.attachAsset('wall5', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 400 + 200 }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { // Move vertically from top to bottom self.x += self.speed; // Move rightwards self.y -= self.speed; // Move upwards if (self.x > game.width || self.y < 0) { self.x = 0; // Reset position to the left self.y = game.height + 200; // Further increase spacing by starting below the screen } }; }); // Create a Wall6 class for walls respawning top to bottom var Wall6 = Container.expand(function () { var self = Container.call(this); // Attach a wall6 asset to represent the wall var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 100 + 50, height: Math.random() * 400 + 200 // Increase height to make walls taller }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards self.y += self.speed; // Move downwards if (self.x < 0 || self.y > game.height) { self.x = game.width; // Reset position to the right self.y = 0; // Reset position to the top } }; }); // Create a Wall6BottomRight class for walls respawning from bottom right corner var Wall6BottomRight = Container.expand(function () { var self = Container.call(this); // Attach a wall6 asset to represent the wall var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = 0; // Reset position to the top self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Wall6DiagonalTopLeft class for walls moving diagonally from top left to bottom right var Wall6DiagonalTopLeft = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 }); self.speed = 6; self.update = function () { self.x += self.speed; // Move rightwards self.y += self.speed; // Move downwards if (self.x > game.width || self.y > game.height) { self.x = 0; // Reset position to the left self.y = 0; // Reset position to the top } }; }); // Create a Wall6DiagonalTopRight class for walls moving diagonally from top right to bottom left var Wall6DiagonalTopRight = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 }); self.speed = 6; self.update = function () { self.x -= self.speed; // Move leftwards self.y += self.speed; // Move downwards if (self.x < 0 || self.y > game.height) { self.x = game.width; // Reset position to the right self.y = 0; // Reset position to the top } }; }); // Create a Wall6Horizontal class for taller horizontal walls spawning from left to right var Wall6Horizontal = Container.expand(function () { var self = Container.call(this); // Attach a wall6 asset to represent the wall var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 400 + 200 // Make the wall wider and random }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards if (self.x > game.width) { self.x = 0; // Reset position to the left when reaching the right edge self.y = Math.random() * (game.height - self.height) + self.height / 2 + 100; // Increase spacing between each respawning wall } }; }); // Create a Wall6HorizontalRight class for walls moving horizontally from right to left var Wall6HorizontalRight = Container.expand(function () { var self = Container.call(this); // Attach a wall6 asset to represent the wall var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 400 + 200 // Make the wall wider and random }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards if (self.x < -self.width) { self.x = game.width; // Reset position to the right when reaching the left edge self.y = Math.random() * (game.height - self.height) + self.height / 2; // Randomize vertical position } }; }); // Create a Wall6TopLeft class for walls respawning randomly with random shapes from the top left corner var Wall6TopLeft = Container.expand(function () { var self = Container.call(this); // Attach a wall6 asset to represent the wall var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards if (self.x > game.width) { self.x = 0; // Reset position to the left self.y = Math.random() * (game.height - self.height) + self.height / 2; // Randomize vertical position } }; }); // Create a Wall6TopRight class for walls moving diagonally from top right to bottom left var Wall6TopRight = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 }); self.speed = 6; self.update = function () { self.x -= self.speed; // Move leftwards self.y += self.speed; // Move downwards if (self.x < 0 || self.y > game.height) { self.x = game.width; // Reset position to the right self.y = 0; // Reset position to the top } }; }); // Create a Wall6Vertical class for taller vertical walls spawning from top to bottom var Wall6Vertical = Container.expand(function () { var self = Container.call(this); // Attach a wall6 asset to represent the wall var wallGraphics = self.attachAsset('wall6', { anchorX: 0.5, anchorY: 0.5, height: Math.random() * 400 + 200 // Make the wall taller and random }); // Set wall speed self.speed = 8; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = 0; // Reset position to the top when reaching the bottom edge self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Wall7 class for walls in level 7 var Wall7 = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall7', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 100 + 50, height: Math.random() * 100 + 50 }); self.speed = 10; self.update = function () { self.y += self.speed; if (self.y > game.height) { self.y = 0; self.x = Math.random() * (game.width - self.width) + self.width / 2; } }; }); var Wall7Diagonal = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall7', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 100 + 50, height: Math.random() * 100 + 50 }); self.speed = 6; self.update = function () { self.x += self.speed; self.y += self.speed; if (self.x > game.width || self.y > game.height) { self.x = 0; self.y = 0; } }; }); var Wall7Horizontal = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall7', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 100 + 50 }); self.speed = 6; self.update = function () { self.x += self.speed; if (self.x > game.width) { self.x = 0; self.y = Math.random() * (game.height - self.height) + self.height / 2; } }; }); // Create a Wall8 class for walls in level 8 var Wall8 = Container.expand(function () { var self = Container.call(this); // Attach a wall8 asset to represent the wall var wallGraphics = self.attachAsset('wall8', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 400 + 200 // Increase height to make walls taller }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = 0; // Reset position to the top self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Wall8BottomRight class for walls spawning from bottom right var Wall8BottomRight = Container.expand(function () { var self = Container.call(this); // Attach a wall8 asset to represent the wall var wallGraphics = self.attachAsset('wall8', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 400 + 200, // Increase height to make walls taller rotation: -Math.PI / 6 // Rotate 30 degrees to the left }); // Set wall speed self.speed = 6; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards self.y -= self.speed; // Move upwards if (self.x < 0 || self.y < 0) { self.x = game.width - 100; // Reset position to the right with spacing self.y = game.height - 100; // Reset position to the bottom with spacing } }; }); // Create a Wall9 class for walls in level 9 var Wall9 = Container.expand(function () { var self = Container.call(this); // Attach a wall9 asset to represent the wall var wallGraphics = self.attachAsset('wall9', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 // Reduce height for level 9 }); // Set wall speed self.speed = 8; // Further increase speed for level 9 // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; // Move downwards if (self.y > game.height) { self.y = 0; // Reset position to the top self.x = Math.random() * (game.width - self.width) + self.width / 2; // Randomize horizontal position } }; }); // Create a Wall9LeftBottom class for walls respawning from left to bottom var Wall9LeftBottom = Container.expand(function () { var self = Container.call(this); // Attach a wall9 asset to represent the wall var wallGraphics = self.attachAsset('wall9', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100, // Reduce height for level 9 rotation: Math.PI / 6 // Rotate 60 degrees to the left }); // Set wall speed self.speed = 8; // Further increase speed for level 9 // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards self.y += self.speed; // Move downwards if (self.x < 0 || self.y > game.height) { self.x = game.width; // Reset position to the right self.y = 0; // Reset position to the top } }; }); // Create a Wall9LeftTop class for walls respawning from left to top var Wall9LeftTop = Container.expand(function () { var self = Container.call(this); // Attach a wall9 asset to represent the wall var wallGraphics = self.attachAsset('wall9', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100, height: Math.random() * 200 + 100 // Reduce height for level 9 }); // Set wall speed self.speed = 8; // Further increase speed for level 9 // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x += self.speed; // Move rightwards self.y -= self.speed; // Move upwards if (self.x > game.width || self.y < 0) { self.x = 0; // Reset position to the left self.y = game.height; // Reset position to the bottom } }; }); // Create a WallHorizontal class for taller horizontal walls spawning from right var WallHorizontal = Container.expand(function () { var self = Container.call(this); // Attach a wall asset to represent the wall var wallGraphics = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 200 + 100 // Reduce the width for level 1 }); // Set wall speed self.speed = 6; // Increase speed for level 1 walls // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards if (self.x < 0) { self.x = game.width; // Reset position to the right when reaching the left edge // Calculate the vertical spacing for 4 lines in the middle var fixedPositions = [game.height / 2 - 5 * player.height, game.height / 2 - 2.5 * player.height, game.height / 2 + 2.5 * player.height, game.height / 2 + 5 * player.height]; var positionIndex = Math.floor(Math.random() * fixedPositions.length); self.y = fixedPositions[positionIndex]; // Removed additional spacing between each respawning wall } }; }); // Create a WallVertical class for vertical walls spawning from top var WallVertical = Container.expand(function () { var self = Container.call(this); // Attach a wall asset to represent the wall var wallGraphics = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 0.5, height: Math.random() * 600 + 300 // Increase height to make walls even taller }); // Set wall speed self.speed = 8; // Increase speed for level 1 walls // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; }; }); // Create a WallVertical2 class for taller vertical walls spawning from top to bottom var WallVertical2 = Container.expand(function () { var self = Container.call(this); // Attach a wall asset to represent the wall var wallGraphics = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 0.5, height: Math.random() * 200 + 100 // Make the wall taller and random }); // Set wall speed self.speed = 4; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ function _typeof2(o) { "@babel/helpers - typeof"; return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof2(o); } function _defineProperty2(e, r, t) { return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey2(t) { var i = _toPrimitive2(t, "string"); return "symbol" == _typeof2(i) ? i : i + ""; } function _toPrimitive2(t, r) { if ("object" != _typeof2(t) || !t) { return t; } var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof2(i)) { return i; } throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) { return t; } var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) { return i; } throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var background = null; function setBackgroundForLevel(level) { if (background) { background.destroy(); // Remove the current background } if (level === 1) { background = game.addChildAt(LK.getAsset('Background1', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background1', {}).width * game.width / LK.getAsset('Background1', {}).width) / 2, y: (game.height - LK.getAsset('Background1', {}).height * game.height / LK.getAsset('Background1', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } else if (level === 2) { levelText.setText('Level 2'); // Update level text for level 2 background = game.addChildAt(LK.getAsset('Background2', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background2', {}).width * game.width / LK.getAsset('Background2', {}).width) / 2, y: (game.height - LK.getAsset('Background2', {}).height * game.height / LK.getAsset('Background2', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } else if (level === 3) { levelText.setText('Level 3'); // Update level text for level 3 background = game.addChildAt(LK.getAsset('Background3', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background3', {}).width * game.width / LK.getAsset('Background3', {}).width) / 2, y: (game.height - LK.getAsset('Background3', {}).height * game.height / LK.getAsset('Background3', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } else if (level === 4) { levelText.setText('Level 4'); // Update level text for level 4 background = game.addChildAt(LK.getAsset('Background4', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background4', {}).width * game.width / LK.getAsset('Background4', {}).width) / 2, y: (game.height - LK.getAsset('Background4', {}).height * game.height / LK.getAsset('Background4', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); if (level === 4) { // Reduce the number of Wall4 instances if (LK.ticks % 200 == 0) { // Increase tick interval for fewer walls var newWall4 = new Wall4(); newWall4.x = Math.random() * (game.width - newWall4.width) + newWall4.width / 2; newWall4.y = Math.random() * (game.height - newWall4.height) + newWall4.height / 2; // Ensure respawn within screen boundaries game.addChild(newWall4); var newWall4DiagonalBottomRight = new Wall4DiagonalBottomRight(); newWall4DiagonalBottomRight.x = Math.random() * (game.width - newWall4DiagonalBottomRight.width) + newWall4DiagonalBottomRight.width / 2; newWall4DiagonalBottomRight.y = Math.random() * (game.height - newWall4DiagonalBottomRight.height) + newWall4DiagonalBottomRight.height / 2; // Ensure respawn within screen boundaries game.addChild(newWall4DiagonalBottomRight); } } } else if (level === 5) { levelText.setText('Level 5'); // Update level text for level 5 background = game.addChildAt(LK.getAsset('Background5', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background5', {}).width * game.width / LK.getAsset('Background5', {}).width) / 2, y: (game.height - LK.getAsset('Background5', {}).height * game.height / LK.getAsset('Background5', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } else if (level === 6) { levelText.setText('Level 6'); // Update level text for level 6 background = game.addChildAt(LK.getAsset('Background6', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background6', {}).width * game.width / LK.getAsset('Background6', {}).width) / 2, y: (game.height - LK.getAsset('Background6', {}).height * game.height / LK.getAsset('Background6', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall6 || game.children[i] instanceof Wall6Horizontal || game.children[i] instanceof Wall6HorizontalRight || game.children[i] instanceof Wall6DiagonalTopLeft || game.children[i] instanceof Wall6DiagonalTopRight) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } if (level === 6 && LK.ticks % 100 == 0) { var newWall6 = new Wall6(); newWall6.x = Math.random() * (game.width - newWall6.width) + newWall6.width / 2; newWall6.y = 0; game.addChild(newWall6); var newWall6DiagonalTopLeft = new Wall6DiagonalTopLeft(); newWall6DiagonalTopLeft.x = 0; // Start from the top left corner newWall6DiagonalTopLeft.y = 0; // Start from the top left corner game.addChild(newWall6DiagonalTopLeft); var newWall6DiagonalTopRight = new Wall6DiagonalTopRight(); newWall6DiagonalTopRight.x = game.width; // Start from the top right corner newWall6DiagonalTopRight.y = 0; // Start from the top right corner game.addChild(newWall6DiagonalTopRight); var newWall6HorizontalRight = new Wall6HorizontalRight(); newWall6HorizontalRight.x = game.width; // Start from the right newWall6HorizontalRight.y = Math.random() * (game.height - newWall6HorizontalRight.height) + newWall6HorizontalRight.height / 2; game.addChild(newWall6HorizontalRight); } for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Wall4 || game.children[i] instanceof Wall4Horizontal || game.children[i] instanceof Wall4Diagonal || game.children[i] instanceof Wall4DiagonalBottomRight) { game.children[i].destroy(); // Remove the wall from the game game.children.splice(i, 1); // Remove the wall from the children array } } // Removed background5 from level 6 } else if (level === 7) { levelText.setText('Level 7'); // Update level text for level 7 background = game.addChildAt(LK.getAsset('Background7', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background7', {}).width * game.width / LK.getAsset('Background7', {}).width) / 2, y: (game.height - LK.getAsset('Background7', {}).height * game.height / LK.getAsset('Background7', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); if (level === 7 && LK.ticks % 100 == 0) { var newWall7 = new Wall7(); newWall7.x = Math.random() * (game.width - newWall7.width) + newWall7.width / 2; newWall7.y = 0; game.addChild(newWall7); var newWall7Horizontal = new Wall7Horizontal(); newWall7Horizontal.x = game.width; newWall7Horizontal.y = Math.random() * (game.height - newWall7Horizontal.height) + newWall7Horizontal.height / 2; game.addChild(newWall7Horizontal); var newWall7Diagonal = new Wall7Diagonal(); newWall7Diagonal.x = game.width; // Start from the right newWall7Diagonal.y = 0; // Start from the top game.addChild(newWall7Diagonal); } } else if (level === 8) { levelText.setText('Level 8'); // Update level text for level 8 background = game.addChildAt(LK.getAsset('Background8', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background8', {}).width * game.width / LK.getAsset('Background8', {}).width) / 2, y: (game.height - LK.getAsset('Background8', {}).height * game.height / LK.getAsset('Background8', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } else if (level === 9) { levelText.setText('Level 9'); // Update level text for level 9 background = game.addChildAt(LK.getAsset('Background9', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background9', {}).width * game.width / LK.getAsset('Background9', {}).width) / 2, y: (game.height - LK.getAsset('Background9', {}).height * game.height / LK.getAsset('Background9', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } else if (level === 10) { levelText.setText('Level 10'); // Update level text for level 10 background = game.addChildAt(LK.getAsset('Background10', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background10', {}).width * game.width / LK.getAsset('Background10', {}).width) / 2, y: (game.height - LK.getAsset('Background10', {}).height * game.height / LK.getAsset('Background10', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } if (background) { background.scale.set(game.width / background.width, game.height / background.height); } } setBackgroundForLevel(level); var level = 1; var levelChangeInterval = 20 * 60; // 20 seconds for all levels at 60 FPS var levelChangeTimer = 0; // Add event listeners for player movement game.down = function (x, y, obj) { LK.setTimeout(function () { targetPosition = { x: x, y: y }; // Set target position to the click position }, 1000); // Delay movement by 1 second }; // Ensure Wall5 objects are not respawning in any level for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall5 || game.children[i] instanceof Wall5Vertical || game.children[i] instanceof Wall5Horizontal) { game.children[i].visible = false; } } var background; if (level === 1) { background = game.addChildAt(LK.getAsset('Background1', { anchorX: 0.0, anchorY: 0.0, width: game.width, height: game.height, x: 0, y: 0 }), 0); } else if (level === 3) { background = game.addChildAt(LK.getAsset('Background3', { anchorX: 0.0, anchorY: 0.0, x: (game.width - LK.getAsset('Background3', {}).width * game.width / LK.getAsset('Background3', {}).width) / 2, y: (game.height - LK.getAsset('Background3', {}).height * game.height / LK.getAsset('Background3', {}).height) / 2 }), 0); background.scale.set(game.width / background.width, game.height / background.height); } // Fit the background to the screen if it is defined if (background) { background.scale.set(game.width / background.width, game.height / background.height); background.width = game.width; background.height = game.height; } // Add level text on 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 right of the top edge of the text. LK.gui.topRight.addChild(levelText); // Initialize 10 background assets for each level for (var i = 1; i <= 10; i++) {} // Add time text on the top left corner var timeText = new Text2('Time: 0', { size: 100, fill: 0x808080 // Grey color }); timeText.anchor.set(0, 0); // Sets anchor to the left of the top edge of the text. LK.gui.topLeft.addChild(timeText); // Initialize a player instance and attach it to the game var player = game.addChild(new Player()); player.x = game.width / 2; player.y = game.height - player.height / 2; // Position player in the middle of the bottom side for all levels if (level === 1) { // Add gate to level 1 var gate = new Gate(); game.addChild(gate); } else if (level === 2) { // Add gate to level 2 var gate = new Gate(); game.addChild(gate); } // Initialize dragNode var dragNode = null; // Initialize dragNode for player dragging // Removed maze regeneration and player reinitialization // Removed player movement and click event listener related to the maze // Function to generate a random maze // Add event listener for player movement // Removed game.down event listener as it's not needed // Update game loop to move player towards target position var targetPosition = null; game.update = function () { if (targetPosition) { var directionX = targetPosition.x - player.x; var directionY = targetPosition.y - player.y; var distance = Math.sqrt(directionX * directionX + directionY * directionY); if (distance > player.speed) { player.x += directionX / distance * player.speed; player.y += directionY / distance * player.speed; } else { player.x = targetPosition.x; player.y = targetPosition.y; targetPosition = null; // Stop moving once the target is reached } player.x = Math.max(player.width / 2, Math.min(game.width - player.width / 2, player.x)); player.y = Math.max(player.height / 2, Math.min(game.height - player.height / 2, player.y)); } // Check for collision between player and gate for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Gate && player.intersects(game.children[i])) { if (level === 10) { level = 1; // Reset to level 1 // Ensure Wall10 objects are not respawning when resetting to level 1 for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall10) { game.children[i].visible = false; } } } else { level++; // Advance to the next level } setBackgroundForLevel(level); // Change the background for the new level levelText.setText('Level ' + level); // Update the level text levelChangeTimer = 0; // Reset the timer player.x = game.width / 2; // Reset player position player.y = game.height - player.height / 2; break; } } // Create random vertical and horizontal walls for wall1 in level 1 only if (level === 1 && LK.ticks % 240 == 0) { // 240 ticks for 4 seconds at 60 FPS for (var i = 0; i < 4; i++) { var newWall1 = new WallHorizontal(); newWall1.x = game.width; var fixedPositions = [game.height / 2 - 3 * player.height, game.height / 2 + 3 * player.height, game.height / 2 - 1.5 * player.height, game.height / 2 + 1.5 * player.height]; newWall1.y = fixedPositions[i]; game.addChild(newWall1); } } else { // Ensure Wall1 objects are not respawning in levels other than 1 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof WallVertical || game.children[i] instanceof WallHorizontal) && level !== 1) { game.children[i].visible = false; } if (level === 2 && LK.ticks % 150 == 0) { for (var i = 0; i < 2; i++) { // Increase the number of walls from the left var newWall2Horizontal = new Wall2Horizontal(); newWall2Horizontal.x = 0; // Start from the left newWall2Horizontal.y = Math.random() * (game.height - newWall2Horizontal.height) + newWall2Horizontal.height / 2; newWall2Horizontal.speed = 8; // Increase speed game.addChild(newWall2Horizontal); var newWall2HorizontalRight = new Wall2HorizontalRight(); newWall2HorizontalRight.x = game.width; // Start from the right newWall2HorizontalRight.y = Math.random() * (game.height - newWall2HorizontalRight.height) + newWall2HorizontalRight.height / 2; game.addChild(newWall2HorizontalRight); } } // Ensure Wall2 objects are visible in level 2 and handle collisions for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall2 || game.children[i] instanceof Wall2Horizontal || game.children[i] instanceof Wall2HorizontalRight) { game.children[i].visible = level === 2; // Ensure visibility only in level 2 if (player.intersects(game.children[i]) && game.children[i].visible) { if (!game.isGameOver) { LK.showGameOver(); game.isGameOver = true; } break; } } } // Ensure Wall1 objects are not visible in level 2 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof WallVertical || game.children[i] instanceof WallHorizontal) && level === 2) { game.children[i].visible = false; } } } } // Add wall3 to level 3 as objects respawning from bottom to top and right to left if (level === 3 && LK.ticks % 150 == 0) { var newWall3HorizontalLeft = new Wall3Right(); newWall3HorizontalLeft.x = 0; newWall3HorizontalLeft.y = Math.random() * (game.height - newWall3HorizontalLeft.height) + newWall3HorizontalLeft.height / 2; newWall3HorizontalLeft.speed = 10; // Further increase speed for level 3 game.addChild(newWall3HorizontalLeft); var newWall3HorizontalRight = new Wall3Right(); newWall3HorizontalRight.x = game.width; newWall3HorizontalRight.y = Math.random() * (game.height - newWall3HorizontalRight.height) + newWall3HorizontalRight.height / 2; newWall3HorizontalRight.speed = -10; // Further increase speed for level 3 game.addChild(newWall3HorizontalRight); // Ensure Wall3 objects are visible in level 3 for (var i = 0; i < game.children.length; i++) {} } else if (level !== 3) { // Ensure Wall3 objects are not respawning in levels other than 3 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall3 || game.children[i] instanceof Wall3Right) && level !== 3) { game.children[i].visible = false; } } } // Add collision detection for Wall3 and Wall3Right in level 3 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall3 || game.children[i] instanceof Wall3Right) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } // Add Wall4 objects to level 4 with horizontal spawning from left to right if (level === 4 && LK.ticks % 100 == 0) { // Increase tick interval for more spacing var newWall4Diagonal = new Wall4Diagonal(); newWall4Diagonal.x = 0; // Start from the top left corner newWall4Diagonal.y = 0; // Start from the top left corner game.addChild(newWall4Diagonal); // Add collision detection for all Wall4 objects in level 4 for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall4 || game.children[i] instanceof Wall4Horizontal || game.children[i] instanceof Wall4Diagonal || game.children[i] instanceof Wall4DiagonalBottomRight) { game.children[i].visible = level === 4; // Ensure visibility only in level 4 if (player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); // Trigger game over immediately return; // Ensure immediate exit from the loop } } } // Reduce frequency by increasing tick interval var newWall4Horizontal = new Wall4(); newWall4Horizontal.x = 0; // Start from the left newWall4Horizontal.y = Math.random() * (game.height - newWall4Horizontal.height) + newWall4Horizontal.height / 2; game.addChild(newWall4Horizontal); // Add multiple vertical walls } else if (level === 5) { // Remove Wall4 and Wall4Vertical objects in level 5 for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Wall4 || game.children[i] instanceof Wall4Vertical) { game.children[i].destroy(); // Remove the wall from the game game.children.splice(i, 1); // Remove the wall from the children array } } // Add Wall5 objects with random shapes in level 5 if (LK.ticks % 120 == 0) { var newWall5Vertical = new Wall5Vertical(); newWall5Vertical.x = Math.random() * (game.width - newWall5Vertical.width) + newWall5Vertical.width / 2; newWall5Vertical.y = 0; game.addChild(newWall5Vertical); var newWall5Horizontal = new Wall5Horizontal(); newWall5Horizontal.x = 0; newWall5Horizontal.y = Math.random() * (game.height - newWall5Horizontal.height) + newWall5Horizontal.height / 2; game.addChild(newWall5Horizontal); } } else { // Ensure Wall5 objects are not respawning in levels other than 5 and 10 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall5 || game.children[i] instanceof Wall5Vertical || game.children[i] instanceof Wall5Horizontal) && level !== 5 && level !== 10) { game.children[i].visible = false; } } } // Add collision detection for Wall5, Wall5Vertical, and Wall5Horizontal in level 5 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall5 || game.children[i] instanceof Wall5Vertical || game.children[i] instanceof Wall5Horizontal) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } // Add Wall6Vertical and Wall6Horizontal objects to level 6 if (level === 7 && levelChangeTimer === 0) { levelChangeTimer = 1; // Start the timer when level 7 begins if (LK.ticks % 100 == 0) { var newWall7 = new Wall7(); newWall7.x = Math.random() * (game.width - newWall7.width) + newWall7.width / 2; newWall7.y = 0; game.addChild(newWall7); var newWall7Horizontal = new Wall7Horizontal(); newWall7Horizontal.x = game.width; newWall7Horizontal.y = Math.random() * (game.height - newWall7Horizontal.height) + newWall7Horizontal.height / 2; game.addChild(newWall7Horizontal); var newWall7Diagonal = new Wall7Diagonal(); newWall7Diagonal.x = game.width; // Start from the right newWall7Diagonal.y = 0; // Start from the top game.addChild(newWall7Diagonal); } // Add Wall6Horizontal objects to level 6 with horizontal spawning from left to right if (level === 6 && LK.ticks % 100 == 0) { var newWall6Horizontal = new Wall6Horizontal(); newWall6Horizontal.x = 0; // Start from the left newWall6Horizontal.y = Math.random() * (game.height - newWall6Horizontal.height) + newWall6Horizontal.height / 2; game.addChild(newWall6Horizontal); var newWall6HorizontalRight = new Wall6HorizontalRight(); newWall6HorizontalRight.x = game.width; // Start from the right newWall6HorizontalRight.y = Math.random() * (game.height - newWall6HorizontalRight.height) + newWall6HorizontalRight.height / 2; game.addChild(newWall6HorizontalRight); var newWall6DiagonalTopLeft = new Wall6DiagonalTopLeft(); newWall6DiagonalTopLeft.x = 0; // Start from the top left corner newWall6DiagonalTopLeft.y = 0; // Start from the top left corner game.addChild(newWall6DiagonalTopLeft); var newWall6DiagonalTopRight = new Wall6DiagonalTopRight(); newWall6DiagonalTopRight.x = game.width; // Start from the top right corner newWall6DiagonalTopRight.y = 0; // Start from the top right corner game.addChild(newWall6DiagonalTopRight); var newWall6 = new Wall6(); newWall6.x = Math.random() * (game.width - newWall6.width) + newWall6.width / 2; newWall6.y = 0; game.addChild(newWall6); } else { // Ensure Wall6 objects are not respawning in levels other than 6 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall6 || game.children[i] instanceof Wall6Horizontal || game.children[i] instanceof Wall6HorizontalRight || game.children[i] instanceof Wall6DiagonalTopLeft || game.children[i] instanceof Wall6DiagonalTopRight) && level !== 6) { game.children[i].visible = false; } } } for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall7 || game.children[i] instanceof Wall7Horizontal || game.children[i] instanceof Wall7Diagonal) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } if (level === 7 && LK.ticks % 100 == 0) { var newWall7 = new Wall7(); newWall7.x = Math.random() * (game.width - newWall7.width) + newWall7.width / 2; newWall7.y = 0; game.addChild(newWall7); var newWall7Horizontal = new Wall7Horizontal(); newWall7Horizontal.x = game.width; newWall7Horizontal.y = Math.random() * (game.height - newWall7Horizontal.height) + newWall7Horizontal.height / 2; game.addChild(newWall7Horizontal); var newWall7Diagonal = new Wall7Diagonal(); newWall7Diagonal.x = game.width; // Start from the right newWall7Diagonal.y = 0; // Start from the top game.addChild(newWall7Diagonal); var newWall7DiagonalTopLeft = new Wall7Diagonal(); newWall7DiagonalTopLeft.x = 0; // Start from the top left corner newWall7DiagonalTopLeft.y = 0; // Start from the top left corner game.addChild(newWall7DiagonalTopLeft); var newWall7DiagonalTopRight = new Wall7Diagonal(); newWall7DiagonalTopRight.x = game.width; // Start from the top right corner newWall7DiagonalTopRight.y = 0; // Start from the top right corner game.addChild(newWall7DiagonalTopRight); var newWall7DiagonalBottomRight = new Wall7Diagonal(); newWall7DiagonalBottomRight.x = game.width; // Start from the bottom right corner newWall7DiagonalBottomRight.y = game.height; // Start from the bottom right corner game.addChild(newWall7DiagonalBottomRight); var newWall7 = new Wall7(); newWall7.x = Math.random() * (game.width - newWall7.width) + newWall7.width / 2; newWall7.y = 0; game.addChild(newWall7); } } } // Add Wall8 objects to level 8 if (level === 8 && LK.ticks % 100 == 0 && levelChangeTimer < levelChangeInterval) { // Remove existing Wall7 objects // Removed references to Wall7 and Wall7Horizontal as they are not defined // Add new Wall8 object var newWall8 = new Wall8(); newWall8.x = Math.random() * (game.width - newWall8.width) + newWall8.width / 2; newWall8.y = 0; game.addChild(newWall8); if (Math.random() < 0.5) { // 50% chance to spawn var newWall8BottomRight = new Wall8BottomRight(); newWall8BottomRight.x = game.width; newWall8BottomRight.y = game.height; game.addChild(newWall8BottomRight); } } // Add collision detection for Wall8 and Wall8BottomRight in level 8 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall8 || game.children[i] instanceof Wall8BottomRight) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } // Add Wall9 objects to level 9 if (level === 9 && LK.ticks % 100 == 0 && levelChangeTimer > 60) { var newWall9 = new Wall9(); newWall9.x = Math.random() * (game.width - newWall9.width) + newWall9.width / 2; newWall9.y = 0; game.addChild(newWall9); if (Math.random() < 0.5) { // 50% chance to spawn Wall9LeftBottom var newWall9LeftBottom = new Wall9LeftBottom(); newWall9LeftBottom.x = 0; // Start from the left newWall9LeftBottom.y = game.height; // Start from the bottom game.addChild(newWall9LeftBottom); } // Hide Wall8 and Wall8BottomRight in level 9 for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall8 || game.children[i] instanceof Wall8BottomRight) { game.children[i].visible = false; } } } else if (level === 10 && LK.ticks % 100 == 0) { // Reduce frequency by increasing tick interval for (var i = 0; i < 2; i++) { // Spawn two Wall10 instances var newWall10; var spawnCorner = Math.floor(Math.random() * 4); // Randomly choose a corner switch (spawnCorner) { case 0: // Top-left corner newWall10 = new Wall10(); newWall10.x = newWall10.width / 2; newWall10.y = newWall10.height / 2; newWall10.update = function () { this.x += this.speed; this.y += this.speed; if (this.x > game.width || this.y > game.height) { this.x = this.width / 2; this.y = this.height / 2; } }; break; case 1: // Top-right corner newWall10 = new Wall10(); newWall10.x = game.width - newWall10.width / 2; newWall10.y = newWall10.height / 2; newWall10.update = function () { this.x -= this.speed; this.y += this.speed; if (this.x < 0 || this.y > game.height) { this.x = game.width - this.width / 2; this.y = this.height / 2; } }; break; } game.addChild(newWall10); } } for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof WallVertical || game.children[i] instanceof WallHorizontal || game.children[i] instanceof WallVertical2 || game.children[i] instanceof Wall6Vertical || game.children[i] instanceof Wall6Horizontal || game.children[i] instanceof Wall9 || game.children[i] instanceof Wall9LeftBottom || game.children[i] instanceof Wall9LeftTop || game.children[i] instanceof Wall8 && level !== 9 || game.children[i] instanceof Wall10) { if (level !== 9 && (game.children[i] instanceof Wall9 || game.children[i] instanceof Wall9LeftBottom || game.children[i] instanceof Wall9LeftTop)) { game.children[i].visible = false; } if (player.intersects(game.children[i]) && game.children[i].visible) { if (!(level === 2 && (game.children[i] instanceof WallVertical || game.children[i] instanceof WallHorizontal) || level === 4 && (game.children[i] instanceof Wall3 || game.children[i] instanceof Wall3Right) || level === 3 && (game.children[i] instanceof Wall3 || game.children[i] instanceof Wall3Right))) { LK.showGameOver(); break; } } } // Removed game over trigger when level 4 starts } // Increment the level change timer levelChangeTimer++; // Check if time in level 7 reaches 20 seconds if (level === 7 && levelChangeTimer >= 20 * 60) { levelChangeTimer = 0; // Reset the timer level++; // Increment the level setBackgroundForLevel(level); // Change the background for the new level levelText.setText('Level ' + level); // Update the level text } // Update the time text to show the current status time timeText.setText('Time: ' + Math.floor(levelChangeTimer / 60)); // Convert ticks to seconds // Check if it's time to change the level if (levelChangeTimer >= levelChangeInterval) { if (level === 10 || levelChangeTimer >= levelChangeInterval) { LK.showGameOver(); return; } levelChangeTimer = 0; // Reset the timer // Reset player position at the start of each new level // Removed player position reset during level change setBackgroundForLevel(level); // Change the background for the new level levelText.setText('Level ' + level); // Update the level text // Ensure player is not released until level changes player.visible = false; LK.setTimeout(function () { player.visible = true; }, 1000); // Delay to release player after level change } }; // Add event listeners for player movement // Define handleMove function function handleMove(x, y, obj) {} game.down = function (x, y, obj) { targetPosition = { x: Math.round(x / player.width) * player.width, // Align to grid y: Math.round(y / player.height) * player.height // Align to grid }; }; game.up = function (x, y, obj) {}; // Removed game.move event listener as it's not needed // Removed player movement towards target position in game update game.up = function (x, y, obj) { dragNode = null; };
===================================================================
--- original.js
+++ change.js
@@ -1188,12 +1188,12 @@
}
// Create random vertical and horizontal walls for wall1 in level 1 only
if (level === 1 && LK.ticks % 240 == 0) {
// 240 ticks for 4 seconds at 60 FPS
- for (var i = 0; i < 2; i++) {
+ for (var i = 0; i < 4; i++) {
var newWall1 = new WallHorizontal();
newWall1.x = game.width;
- var fixedPositions = [game.height / 2 - 3 * player.height, game.height / 2 + 3 * player.height];
+ var fixedPositions = [game.height / 2 - 3 * player.height, game.height / 2 + 3 * player.height, game.height / 2 - 1.5 * player.height, game.height / 2 + 1.5 * player.height];
newWall1.y = fixedPositions[i];
game.addChild(newWall1);
}
} else {