User prompt
fit the rectangle of the surrounding walls to the image don't make it outside it.
User prompt
Make the walls surround the image lines
User prompt
Make 4 lines of wall1 surround the background1.
User prompt
Make walls around the background1 from inside
User prompt
Please fix the bug: 'Uncaught ReferenceError: wall is not defined' in or related to this line: 'if (obj === wall) {' Line Number: 99
User prompt
Add wall1 to the game
User prompt
Remove wall asset
User prompt
Remove wall
User prompt
Rename the asset wall wall1
Code edit (1 edits merged)
Please save this source code
User prompt
Rename wall wall1
User prompt
add drag function to the wall
User prompt
Set wall in the middle
Code edit (5 edits merged)
Please save this source code
User prompt
Create and generate a maze with random shapes of wall asset in the front of the background1 image and same resolution of it.
User prompt
Make maze with wall asset make it on the front of background1 image.
User prompt
Make maze With same size of the background1
User prompt
Add wall asset. add wall to the game. make the wall same size as player.
User prompt
Make the sides of the image background1 not passable by the player.
Code edit (1 edits merged)
Please save this source code
User prompt
Make player a bit small.
Code edit (2 edits merged)
Please save this source code
User prompt
Rest player position to bottom right
User prompt
Lower it to the bottom
User prompt
Scale it more
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Class for the player character var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 1.9, anchorY: 1.9 }); self.speed = 10; // Increase player's speed attribute self.update = function () { // Player update logic }; }); // Class for the wall var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall1', { anchorX: 1.9, anchorY: 1.9 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Add background to the game var background = game.attachAsset('Background1', { anchorX: 0.5, anchorY: 1, x: 2048 / 2, y: 2732, scaleX: 2048 / 1000, scaleY: (2732 - LK.gui.top.height - 200) / 1000 // Scale down from the top by 200 pixels }); // Set level to 1 game.level = 1; // Initialize player var player = new Player(); player.x = 2048; player.y = 2732; game.addChild(player); // Initialize walls for (var i = background.x - background.width / 2; i < background.x + background.width / 2; i += 80) { var wallTop = new Wall(); wallTop.x = i; wallTop.y = background.y - background.height / 2; game.addChild(wallTop); } for (var i = background.x - background.width / 2; i < background.x + background.width / 2; i += 80) { var wallBottom = new Wall(); wallBottom.x = i; wallBottom.y = background.y + background.height / 2 - 80; game.addChild(wallBottom); } for (var i = background.y - background.height / 2 + 80; i < background.y + background.height / 2 - 80; i += 80) { var wallLeft = new Wall(); wallLeft.x = background.x - background.width / 2; wallLeft.y = i; game.addChild(wallLeft); } for (var i = background.y - background.height / 2 + 80; i < background.y + background.height / 2 - 80; i += 80) { var wallRight = new Wall(); wallRight.x = background.x + background.width / 2 - 80; wallRight.y = i; game.addChild(wallRight); } // Add Level 1 text on the top right var levelText = new Text2('Level 1', { size: 100, fill: 0xFFFFFF, font: "'Time new roman'" }); levelText.anchor.set(1, 0); // Sets anchor to the top right edge of the text. LK.gui.topRight.addChild(levelText); // Handle player movement // Import tween plugin game.down = function (x, y, obj) { var targetX = x; var targetY = y; var dx = targetX - player.x; var dy = targetY - player.y; if (Math.abs(dx) > Math.abs(dy)) { // Move horizontally tween(player, { x: player.x + Math.sign(dx) * player.speed * 10 }, { duration: 500 }); } else { // Move vertically tween(player, { y: player.y + Math.sign(dy) * player.speed * 10 }, { duration: 500 }); } // Drag wall if (obj === wall1) { wall1.x = x; wall1.y = y; } };
===================================================================
--- original.js
+++ change.js
@@ -53,29 +53,29 @@
player.x = 2048;
player.y = 2732;
game.addChild(player);
// Initialize walls
-for (var i = 0; i < 2048; i += 80) {
+for (var i = background.x - background.width / 2; i < background.x + background.width / 2; i += 80) {
var wallTop = new Wall();
wallTop.x = i;
- wallTop.y = 0;
+ wallTop.y = background.y - background.height / 2;
game.addChild(wallTop);
}
-for (var i = 0; i < 2048; i += 80) {
+for (var i = background.x - background.width / 2; i < background.x + background.width / 2; i += 80) {
var wallBottom = new Wall();
wallBottom.x = i;
- wallBottom.y = 2732 - 80;
+ wallBottom.y = background.y + background.height / 2 - 80;
game.addChild(wallBottom);
}
-for (var i = 80; i < 2732 - 80; i += 80) {
+for (var i = background.y - background.height / 2 + 80; i < background.y + background.height / 2 - 80; i += 80) {
var wallLeft = new Wall();
- wallLeft.x = 0;
+ wallLeft.x = background.x - background.width / 2;
wallLeft.y = i;
game.addChild(wallLeft);
}
-for (var i = 80; i < 2732 - 80; i += 80) {
+for (var i = background.y - background.height / 2 + 80; i < background.y + background.height / 2 - 80; i += 80) {
var wallRight = new Wall();
- wallRight.x = 2048 - 80;
+ wallRight.x = background.x + background.width / 2 - 80;
wallRight.y = i;
game.addChild(wallRight);
}
// Add Level 1 text on the top right