User prompt
Make the horizontal walls thin horizontal in level 1.
User prompt
Make the horizontal walls thin vertical in level 1.
User prompt
Make the horizontal walls thin in level 1
User prompt
Make the vertical walls taller in level 1
User prompt
Change shape of Wall4 that respawns from the top to 400x100.
User prompt
Respawn vertical only from top and horizontal shapes from left in level 4.
User prompt
Change shape of Wall4Vertical that respawns from the left to 100x400
User prompt
Change shape of Wall4Vertical that respawns from the left to 400x100.
User prompt
Change shape of Wall4 that respawns from the top to 100x400.
User prompt
Change shape of Wall4 that respawns from the top to 400x100. Change shape of Wall4Vertical that respawns from the left to 100x400.
User prompt
Change shape of the wall4 that respawn from the top 100x400. Change the shape of the wall4 that respawning from the left 400x100.
User prompt
Make th vertical walls of left side only larger and thin horizontally
User prompt
Make the vertical walls thinner horizontally
User prompt
Make the top walls thick and big a bit in level4. Make the left walls smaller not taller at all
User prompt
Make all the walls from left square smaller
User prompt
Make only vertical walls from top and taller a bit in level 4. Make only thin larger walls from left in level 4.
User prompt
Make the left walls thinner vertical more
User prompt
Make the left walls not taller make it taller horizontal
User prompt
Make the left walls thicker and larger horizontal in level 4
User prompt
Make top walls taller and the left walls thinner verticall and larger
User prompt
Make time in all levels 10 sec
User prompt
Make it big a bit the top walls in level 4
User prompt
Make top walls more taller vertically for level 4
User prompt
Make walls from top taller and thinner in level 4
User prompt
1-Make the walls from top taller vertical for level 4. 2- make the horizontal walls larger and thinner vertically for level 4
/**** * Classes ****/ // 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 = 50; // This is automatically called every game tick, if the player is attached! self.update = function () { // No continuous movement }; }); // 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 Wall2 class for walls spawning randomly with random shapes from top to bottom and left to right 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() * 100 + 50, // Random width height: Math.random() * 600 + 300 // Further increase height to make walls even taller }); // 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; // Move downwards vertically 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 } 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 Wall3 class for walls spawning from bottom to top and right to left 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() * 100 + 50, // Random width height: Math.random() * 400 + 200 // Increase height to make walls taller }); // 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; // Move upwards }; }); // 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() * 200 + 100, // Random width height: Math.random() * 200 + 100 // Random height }); // Set wall speed self.speed = 4; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; // Move leftwards }; }); // 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: Math.random() * 100 + 50, // Random width height: Math.random() * 1000 + 500 // Make top walls taller for level 4 }); // Set wall speed self.speed = 4; // 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; // Randomize vertical position } }; }); // 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', {}); // Set wall speed self.speed = 4; // This is automatically called every game tick, if the wall is attached! self.update = function () { if (Math.random() < 0.5) { self.x -= self.speed; // Move leftwards } else { self.x += self.speed; // Move rightwards } }; }); // 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: Math.random() * 50 + 25, // Make the wall thinner vertically for level 4 height: Math.random() * 1000 + 500 // Make the wall larger }); // 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; // 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 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 = 4; // This is automatically called every game tick, if the wall is attached! self.update = function () { // Move vertically from top to bottom 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 } // 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() * 200 + 100, height: Math.random() * 200 + 100 }); // Set wall speed self.speed = 4; // 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; // Randomize vertical position } }; }); // 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() * 200 + 100 }); // Set wall speed self.speed = 4; // This is automatically called every game tick, if the wall is attached! self.update = function () { // Move vertically from top to bottom self.y += self.speed; 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 Wall6 class for walls respawning from bottom to top 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 = 4; // 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; // Randomize vertical position } }; }); // 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 = 4; // 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 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 = 4; // 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; // 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 = 4; // 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 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 = 4; // 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 respawning from different directions var Wall7 = Container.expand(function () { var self = Container.call(this); // Attach a wall7 asset to represent the wall var wallGraphics = self.attachAsset('wall7', { 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 = 4; // 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 Wall7Horizontal class for walls respawning from left to right var Wall7Horizontal = Container.expand(function () { var self = Container.call(this); // Attach a wall7 asset to represent the wall var wallGraphics = self.attachAsset('wall7', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 400 + 200 // Make the wall wider and random }); // Set wall speed self.speed = 4; // 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; // Randomize vertical position } }; }); // Create a Wall7Vertical class for walls respawning from top to bottom var Wall7Vertical = Container.expand(function () { var self = Container.call(this); // Attach a wall7 asset to represent the wall var wallGraphics = self.attachAsset('wall7', { anchorX: 0.5, anchorY: 0.5, height: Math.random() * 400 + 200 // 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; // 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 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 = 4; // 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 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() * 400 + 200 // Increase height to make walls taller }); // 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; // 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 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() * 600 + 300 // Make the wall even wider and random }); // Set wall speed self.speed = 4; // This is automatically called every game tick, if the wall is attached! self.update = function () { self.x -= self.speed; }; }); // 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() * 400 + 200 // 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; }; }); // 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) { 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); } 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); } 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); } 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); } if (background) { background.scale.set(game.width / background.width, game.height / background.height); } } setBackgroundForLevel(level); var level = 1; var levelChangeInterval = 10 * 60; // 10 seconds for all levels at 60 FPS var levelChangeTimer = 0; // Add Wall7 objects moving from bottom-left in level 7 if (level === 7) { if (LK.ticks % 60 == 0) { var newWall7 = new Wall7(); newWall7.x = 0; // Start from the left newWall7.y = game.height - newWall7.height; // Start from the bottom newWall7.visible = true; // Ensure visibility game.addChild(newWall7); } if (LK.ticks % 60 == 0) { var newWall7 = new Wall7(); newWall7.x = Math.random() * (game.width - newWall7.width); // Ensure Wall7 spawns within screen boundaries newWall7.y = 0; // Start from the top newWall7.visible = true; // Ensure visibility game.addChild(newWall7); var newWall7Horizontal = new Wall7Horizontal(); newWall7Horizontal.x = 0; newWall7Horizontal.y = Math.random() * (game.height - newWall7Horizontal.height) + newWall7Horizontal.height / 2; game.addChild(newWall7Horizontal); var newWall7Vertical = new Wall7Vertical(); newWall7Vertical.x = Math.random() * (game.width - newWall7Vertical.width) + newWall7Vertical.width / 2; newWall7Vertical.y = 0; game.addChild(newWall7Vertical); } // Ensure Wall7 objects are visible and can be touched for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall7 && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } } // 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 === 2) { background = game.addChildAt(LK.getAsset('Background2', { 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()); // Position player at the center of the screen player.x = game.width / 2; player.y = game.height / 2; // Show player on the screen for level 2 if (level === 2) { player.visible = true; player.x = game.width / 2; player.y = 0; } // Initialize dragNode var dragNode = null; // 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 dx = targetPosition.x - player.x; var dy = targetPosition.y - player.y; var angle = Math.atan2(dy, dx); player.x += Math.cos(angle) * player.speed; player.y += Math.sin(angle) * player.speed; } // Create random vertical and horizontal walls for wall1 in level 1 only if (level === 1 && LK.ticks % 30 == 0) { var newWall1; if (Math.random() < 0.5) { newWall1 = new WallVertical(); newWall1.x = Math.random() * (game.width - newWall1.width) + newWall1.width / 2; newWall1.y = 0; } else { newWall1 = new WallHorizontal(); newWall1.x = game.width; newWall1.y = Math.random() * (game.height - newWall1.height) + newWall1.height / 2; } game.addChild(newWall1); } // Hide Wall1 objects in level 2 if (level === 2) { for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof WallVertical || game.children[i] instanceof WallHorizontal) { game.children[i].visible = false; } } } // Add Wall2 objects respawning randomly with random shapes moving vertically from top to bottom for level 2 if (level === 2 && LK.ticks % 60 == 0) { var newWall2Vertical = new Wall2(); newWall2Vertical.x = Math.random() * (game.width - newWall2Vertical.width) + newWall2Vertical.width / 2; newWall2Vertical.y = 0; game.addChild(newWall2Vertical); var newWall2Bottom = new Wall2(); newWall2Bottom.x = Math.random() * (game.width - newWall2Bottom.width) + newWall2Bottom.width / 2; newWall2Bottom.y = game.height; newWall2Bottom.speed = -4; // Move upwards game.addChild(newWall2Bottom); } // Add wall3 to level 3 as objects respawning from bottom to top and right to left if (level === 3 && LK.ticks % 60 == 0) { var newWall3 = new Wall3(); newWall3.x = Math.random() * (game.width - newWall3.width) + newWall3.width / 2; newWall3.y = game.height; game.addChild(newWall3); var newWall3Right = new Wall3Right(); newWall3Right.x = game.width; newWall3Right.y = Math.random() * (game.height - newWall3Right.height) + newWall3Right.height / 2; game.addChild(newWall3Right); // Ensure Wall3 objects are visible in level 3 for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Wall2) { game.children[i].visible = false; } } } 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) { 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 % 120 == 0) { // 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); if (Math.random() < 0.5) { // Randomly decide to add a vertical wall var newWall4Vertical = new Wall4Vertical(); newWall4Vertical.x = Math.random() * (game.width - newWall4Vertical.width) + newWall4Vertical.width / 2; newWall4Vertical.y = 0; // Start from the top game.addChild(newWall4Vertical); } } 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 % 60 == 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 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; } } } // 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 === 6 && LK.ticks % 60 == 0) { var newWall6Vertical = new Wall6Vertical(); newWall6Vertical.x = Math.random() * (game.width - newWall6Vertical.width) + newWall6Vertical.width / 2; newWall6Vertical.y = 0; game.addChild(newWall6Vertical); var newWall6Horizontal = new Wall6Horizontal(); newWall6Horizontal.x = 0; newWall6Horizontal.y = Math.random() * (game.height - newWall6Horizontal.height) + newWall6Horizontal.height / 2; game.addChild(newWall6Horizontal); } if (level === 7) { if (LK.ticks % 60 == 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 = 0; newWall7Horizontal.y = Math.random() * (game.height - newWall7Horizontal.height) + newWall7Horizontal.height / 2; game.addChild(newWall7Horizontal); var newWall7Vertical = new Wall7Vertical(); newWall7Vertical.x = Math.random() * (game.width - newWall7Vertical.width) + newWall7Vertical.width / 2; newWall7Vertical.y = 0; game.addChild(newWall7Vertical); } // Add collision detection for Wall7, Wall7Horizontal, and Wall7Vertical in level 7 for (var i = 0; i < game.children.length; i++) { if ((game.children[i] instanceof Wall7 || game.children[i] instanceof Wall7Horizontal || game.children[i] instanceof Wall7Vertical) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Wall6Vertical || game.children[i] instanceof Wall6Horizontal) { game.children[i].destroy(); // Remove the wall from the game game.children.splice(i, 1); // Remove the wall from the children array } } } // Add Wall8 objects to level 8 if (level === 8 && LK.ticks % 60 == 0) { // Remove existing Wall7 objects for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Wall7 || game.children[i] instanceof Wall7Horizontal || game.children[i] instanceof Wall7Vertical) { game.children[i].destroy(); game.children.splice(i, 1); } } // Remove existing Wall8 objects for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Wall8) { game.children[i].destroy(); game.children.splice(i, 1); } } // 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); } // Add Wall9 objects to level 9 if (level === 9 && LK.ticks % 60 == 0) { var newWall9 = new Wall9(); newWall9.x = Math.random() * (game.width - newWall9.width) + newWall9.width / 2; newWall9.y = 0; game.addChild(newWall9); } for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof WallVertical || game.children[i] instanceof WallHorizontal || game.children[i] instanceof Wall2 || game.children[i] instanceof WallVertical2 || game.children[i] instanceof Wall6Vertical || game.children[i] instanceof Wall6Horizontal || game.children[i] instanceof Wall8 || game.children[i] instanceof Wall9) { 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; } } } if (level === 4 && (game.children[i] instanceof Wall4 || game.children[i] instanceof Wall4Vertical) && player.intersects(game.children[i]) && game.children[i].visible) { LK.showGameOver(); break; } } // Increment the level change timer levelChangeTimer++; // Check if time in level 7 reaches 5 seconds if (level === 7 && levelChangeTimer >= 5 * 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) { levelChangeTimer = 0; // Reset the timer level++; // Increment the level if (level > 9) { level = 1; } // Loop back to level 1 after level 6 setBackgroundForLevel(level); // Change the background for the new level levelText.setText('Level ' + level); // Update the level text } }; // Add event listeners for player movement // Define handleMove function function handleMove(x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; } } game.down = function (x, y, obj) { dragNode = player; handleMove(x, y, obj); }; game.move = handleMove; // 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
@@ -109,9 +109,9 @@
anchorX: 0.5,
anchorY: 0.5,
width: Math.random() * 100 + 50,
// Random width
- height: Math.random() * 800 + 400 // Make top walls taller for level 4
+ height: Math.random() * 1000 + 500 // Make top walls taller for level 4
});
// Set wall speed
self.speed = 4;
// This is automatically called every game tick, if the wall is attached!
@@ -143,11 +143,11 @@
var Wall4Vertical = Container.expand(function () {
var self = Container.call(this);
// Attach a wall4 asset to represent the wall
var wallGraphics = self.attachAsset('wall4', {
- width: Math.random() * 100 + 50,
+ width: Math.random() * 50 + 25,
// Make the wall thinner vertically for level 4
- height: Math.random() * 800 + 400 // Make the wall larger
+ height: Math.random() * 1000 + 500 // Make the wall larger
});
// Set wall speed
self.speed = 4;
// This is automatically called every game tick, if the wall is attached!