User prompt
Add movements to the player up down right left.
User prompt
Make player follow continuously the cursor
User prompt
Teleport player to cursor if click nywhere on the screen
User prompt
hold player to move it
User prompt
If moved cursor on the screen make the player follow it by click on the screen
User prompt
Make it follow the corsor exact same time without click on it
User prompt
Move player up and down by click
User prompt
Add movements left right down up
User prompt
Make it follow corsor
User prompt
Make movement of player up left right bottom
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'self.x = game.mouse.x;' Line Number: 29
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var dx = game.mouse.x - self.x;' Line Number: 22
User prompt
Add player and movements by follow cursor exact same time in all directions
User prompt
Make the time text before time
User prompt
Make time and level texts big
User prompt
Add level text on the top right corner grey color big text. add time on the left side 10 sec each level
User prompt
Make the backgrounds all 800x800 and fit it to screen
User prompt
Create 10 levels and 10 backgrounds assets for it.
User prompt
Remove all the game
User prompt
Make theImage1 behind everything in level 1
User prompt
Add assets Image1 to game background to game
User prompt
Ensure that object respawn in the front of background assets Image
User prompt
Make Image1 behind walls
User prompt
Let the walls been front ofimage1
User prompt
Let the walls been on the background
/**** * Classes ****/ var BottomWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y -= 5; if (self.y < 0) { self.destroy(); } }; }); var HorizontalTopWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5, scaleX: 3 // Increase width to make it even wider }); self.update = function () { self.y += 5; // Move downwards if (self.y > 2732) { self.destroy(); } }; }); var LeftWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x -= 5; if (self.x < 0) { self.destroy(); } }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { for (var i = 0; i < mazeWalls.length; i++) { if (self.intersects(mazeWalls[i]) && mazeWalls[i].parent) { var dx = self.x - mazeWalls[i].x; var dy = self.y - mazeWalls[i].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < self.width / 2 + mazeWalls[i].width / 2) { LK.showGameOver(); } } } }; }); var RightWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x += 5; if (self.x > 2048) { self.destroy(); } }; }); var TopWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 5; if (self.y > 2732) { self.destroy(); } }; }); var VerticalWall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5, scaleY: 2 // Increase height to make it taller }); self.update = function () { self.y += 5; if (self.y > 2732) { self.y = 0; } else if (self.y < 0) { self.y = 2732; } }; }); var Wall1 = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, // Make it thinner scaleY: 3 // Make it even taller }); self.update = function () { self.y += 5; if (self.y > 2732) { self.destroy(); } }; }); var Wall2 = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall2', { anchorX: 0.5, anchorY: 0.5, scaleY: Math.random() * 0.5 + 0.5 // Random height between 0.5 and 1 }); self.update = function () { self.x -= 5; if (self.x < 0) { self.destroy(); } }; }); var Wall3 = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall3', { anchorX: 0.5, anchorY: 0.5, scaleX: Math.random() * 0.5 + 0.5, // Random width between 0.5 and 1 scaleY: Math.random() * 2 + 1 // Random height between 1 and 3 }); self.update = function () { self.y -= 5; // Move upwards if (self.y < 0) { self.destroy(); } }; }); /**** * Initialize Game ****/ // Removed maze regeneration and player reinitialization // Removed player movement and click event listener related to the maze // Function to generate a random maze var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Add event listener for player movement // Update game loop to move maze walls 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); } game.move = function (x, y, obj) { player.x = Math.max(player.width / 2, Math.min(game.width - player.width / 2, x)); player.y = Math.max(player.height / 2, Math.min(game.height - player.height / 2, y)); }; var mazeWalls = []; moveMazeWalls(); // Removed duplicate interval creation for generateMazeWall function generateMazeWall() { var wall; if (level === 1) { var background = LK.getAsset('Image1', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, // Scale to fit the width of the screen scaleY: 2732 / 100 // Scale to fit the height of the screen }); background.x = 2048 / 2; background.y = 2732 / 2; game.addChild(background); game.addChild(wall); // Add wall to the background if (Math.random() > 0.5) { wall = new Wall1(); wall.scaleX = Math.random() * 0.5 + 0.5; // Randomize thickness between 0.5 and 1 wall.scaleY = Math.random() * 0.5 + 0.5; // Randomize height between 0.5 and 1 wall.x = Math.random() * (2048 - wall.width) + wall.width / 2; // Random x position within bounds wall.y = 0; // Start from the top } else { wall = new LeftWall(); wall.scaleX = Math.random() * 2 + 1; // Random width between 1 and 3 wall.scaleY = Math.random() * 2 + 1; // Random height between 1 and 3 wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; // Random y position within bounds wall.x = 2048; // Start from the right } } else if (level === 2) { game.setBackgroundColor(0x000000); // Reset background color to black game.addChild(wall); // Add wall to the background if (Math.random() > 0.5) { wall = new Wall2(); wall.scaleX = Math.random() * 2 + 1; // Random width between 1 and 3 wall.scaleY = Math.random() * 3 + 1; // Random height between 1 and 4 wall.x = 2048; // Start from the right wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; // Random y position within bounds } else { wall = new Wall1(); wall.x = Math.random() * (2048 - wall.width) + wall.width / 2; // Random x position within bounds wall.y = 0; // Start from the top } } else if (level === 3) { game.setBackgroundColor(0x000000); // Reset background color to black game.addChild(wall); // Add wall to the background if (Math.random() > 0.3) { wall = new Wall1(); wall.scaleX = Math.random() * 3 + 2; // Random width between 2 and 5 wall.scaleY = Math.random() * 0.2 + 0.2; // Random height between 0.2 and 0.4 wall.x = 0; // Start from the left wall.update = function () { this.x += 5; // Move to the right if (this.x > 2048) { this.destroy(); } }; wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; // Random y position within bounds } else { wall = new Wall3(); wall.scaleX = Math.random() * 1.5 + 0.5; // Random width between 0.5 and 2 wall.scaleY = Math.random() * 1.5 + 0.5; // Random height between 0.5 and 2 wall.x = Math.random() * (2048 - wall.width) + wall.width / 2; // Random x position within bounds wall.y = 2732; // Start from the bottom } } mazeWalls.push(wall); game.addChild(wall); } function moveMazeWalls() { // Removed wall update logic // Ensure no walls are respawned in this function } LK.setInterval(generateMazeWall, 300); // Update timer every second LK.setInterval(function () { timer--; var seconds = timer; timerText.setText('Time: ' + (seconds < 10 ? '0' : '') + seconds); // If time is up, go to next level if (timer <= 0) { level++; if (level == 3) { timer = 10; // 10 seconds for level 3 } else if (level == 10) { LK.showGameOver(); // End the game at level 10 } levelText.setText('Level: ' + level); } // Remove lag when reach 5 sec // Removed premature interval clearing logic }, 1000); var player = new Player(); game.addChild(player); player.x = 2048 / 2; player.y = 2732 / 2; // Initialize timer and level variables var timer = 10; // 10 seconds for level 1 and level 2 var level = 1; // Add level text to 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 top right corner of the text. LK.gui.topRight.addChild(levelText); // Add timer text to the top left corner var timerText = new Text2('Time: 10', { size: 100, fill: 0x808080 // Grey color }); timerText.anchor.set(0, 0); // Sets anchor to the top left corner of the text. LK.gui.topLeft.addChild(timerText); ;
/****
* Classes
****/
var BottomWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y -= 5;
if (self.y < 0) {
self.destroy();
}
};
});
var HorizontalTopWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3 // Increase width to make it even wider
});
self.update = function () {
self.y += 5; // Move downwards
if (self.y > 2732) {
self.destroy();
}
};
});
var LeftWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= 5;
if (self.x < 0) {
self.destroy();
}
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
for (var i = 0; i < mazeWalls.length; i++) {
if (self.intersects(mazeWalls[i]) && mazeWalls[i].parent) {
var dx = self.x - mazeWalls[i].x;
var dy = self.y - mazeWalls[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < self.width / 2 + mazeWalls[i].width / 2) {
LK.showGameOver();
}
}
}
};
});
var RightWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x += 5;
if (self.x > 2048) {
self.destroy();
}
};
});
var TopWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += 5;
if (self.y > 2732) {
self.destroy();
}
};
});
var VerticalWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5,
scaleY: 2 // Increase height to make it taller
});
self.update = function () {
self.y += 5;
if (self.y > 2732) {
self.y = 0;
} else if (self.y < 0) {
self.y = 2732;
}
};
});
var Wall1 = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
// Make it thinner
scaleY: 3 // Make it even taller
});
self.update = function () {
self.y += 5;
if (self.y > 2732) {
self.destroy();
}
};
});
var Wall2 = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall2', {
anchorX: 0.5,
anchorY: 0.5,
scaleY: Math.random() * 0.5 + 0.5 // Random height between 0.5 and 1
});
self.update = function () {
self.x -= 5;
if (self.x < 0) {
self.destroy();
}
};
});
var Wall3 = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: Math.random() * 0.5 + 0.5,
// Random width between 0.5 and 1
scaleY: Math.random() * 2 + 1 // Random height between 1 and 3
});
self.update = function () {
self.y -= 5; // Move upwards
if (self.y < 0) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
// Removed maze regeneration and player reinitialization
// Removed player movement and click event listener related to the maze
// Function to generate a random maze
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Add event listener for player movement
// Update game loop to move maze walls
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);
}
game.move = function (x, y, obj) {
player.x = Math.max(player.width / 2, Math.min(game.width - player.width / 2, x));
player.y = Math.max(player.height / 2, Math.min(game.height - player.height / 2, y));
};
var mazeWalls = [];
moveMazeWalls();
// Removed duplicate interval creation for generateMazeWall
function generateMazeWall() {
var wall;
if (level === 1) {
var background = LK.getAsset('Image1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2048 / 100,
// Scale to fit the width of the screen
scaleY: 2732 / 100 // Scale to fit the height of the screen
});
background.x = 2048 / 2;
background.y = 2732 / 2;
game.addChild(background);
game.addChild(wall); // Add wall to the background
if (Math.random() > 0.5) {
wall = new Wall1();
wall.scaleX = Math.random() * 0.5 + 0.5; // Randomize thickness between 0.5 and 1
wall.scaleY = Math.random() * 0.5 + 0.5; // Randomize height between 0.5 and 1
wall.x = Math.random() * (2048 - wall.width) + wall.width / 2; // Random x position within bounds
wall.y = 0; // Start from the top
} else {
wall = new LeftWall();
wall.scaleX = Math.random() * 2 + 1; // Random width between 1 and 3
wall.scaleY = Math.random() * 2 + 1; // Random height between 1 and 3
wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; // Random y position within bounds
wall.x = 2048; // Start from the right
}
} else if (level === 2) {
game.setBackgroundColor(0x000000); // Reset background color to black
game.addChild(wall); // Add wall to the background
if (Math.random() > 0.5) {
wall = new Wall2();
wall.scaleX = Math.random() * 2 + 1; // Random width between 1 and 3
wall.scaleY = Math.random() * 3 + 1; // Random height between 1 and 4
wall.x = 2048; // Start from the right
wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; // Random y position within bounds
} else {
wall = new Wall1();
wall.x = Math.random() * (2048 - wall.width) + wall.width / 2; // Random x position within bounds
wall.y = 0; // Start from the top
}
} else if (level === 3) {
game.setBackgroundColor(0x000000); // Reset background color to black
game.addChild(wall); // Add wall to the background
if (Math.random() > 0.3) {
wall = new Wall1();
wall.scaleX = Math.random() * 3 + 2; // Random width between 2 and 5
wall.scaleY = Math.random() * 0.2 + 0.2; // Random height between 0.2 and 0.4
wall.x = 0; // Start from the left
wall.update = function () {
this.x += 5; // Move to the right
if (this.x > 2048) {
this.destroy();
}
};
wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; // Random y position within bounds
} else {
wall = new Wall3();
wall.scaleX = Math.random() * 1.5 + 0.5; // Random width between 0.5 and 2
wall.scaleY = Math.random() * 1.5 + 0.5; // Random height between 0.5 and 2
wall.x = Math.random() * (2048 - wall.width) + wall.width / 2; // Random x position within bounds
wall.y = 2732; // Start from the bottom
}
}
mazeWalls.push(wall);
game.addChild(wall);
}
function moveMazeWalls() {
// Removed wall update logic
// Ensure no walls are respawned in this function
}
LK.setInterval(generateMazeWall, 300);
// Update timer every second
LK.setInterval(function () {
timer--;
var seconds = timer;
timerText.setText('Time: ' + (seconds < 10 ? '0' : '') + seconds);
// If time is up, go to next level
if (timer <= 0) {
level++;
if (level == 3) {
timer = 10; // 10 seconds for level 3
} else if (level == 10) {
LK.showGameOver(); // End the game at level 10
}
levelText.setText('Level: ' + level);
}
// Remove lag when reach 5 sec
// Removed premature interval clearing logic
}, 1000);
var player = new Player();
game.addChild(player);
player.x = 2048 / 2;
player.y = 2732 / 2;
// Initialize timer and level variables
var timer = 10; // 10 seconds for level 1 and level 2
var level = 1;
// Add level text to 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 top right corner of the text.
LK.gui.topRight.addChild(levelText);
// Add timer text to the top left corner
var timerText = new Text2('Time: 10', {
size: 100,
fill: 0x808080 // Grey color
});
timerText.anchor.set(0, 0); // Sets anchor to the top left corner of the text.
LK.gui.topLeft.addChild(timerText);
;