User prompt
Remove distance between cursor and player
User prompt
Make it follow cursor exact same time
User prompt
Don't let any distance between cursor and the player let it continue its movement till reach the cursor clicked point.
User prompt
Add distance to the movement of the player
User prompt
Add drag option for wall1 to move it anywhere in the screen.
User prompt
Add drag option with cursor for the walls
User prompt
Make it taller as the screen line of the bottom.
User prompt
Move it a little bit to the right
User prompt
Make it more taller horizontal
User prompt
Make it more taller horizontally between same size as bottom line of the screen
User prompt
Make it more taller as the bottom line of the screen
User prompt
Make it more tall from the right side to reach the other corner.
User prompt
Make its tall from left to the right sides
User prompt
Move the wall a bit to reach the left corner
User prompt
Add drage class and logic for wall1 to move it anywhere on the screen.
User prompt
center the wall1 in the bottom
User prompt
Move the wall1 to the right
User prompt
Make the bottom wall tallto thesides
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Move the wall to bottom middle
User prompt
Set it to the bottom
User prompt
Add tall wall1 to the bottom side
User prompt
Resize the walls to fit the image background1.
User prompt
Make 4 lines of many wall1 surrounding the image of background1 and with its same resolution and scale size.
/**** * 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: 0.05, anchorY: 0.05 }); }); /**** * 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 wall1 var wall1 = new Wall(); wall1.x = 50; // Move wall1 a little bit to the right wall1.y = 2732 - wall1.height; // Position wall1 at the bottom of the screen wall1.width = 2048; // Make wall1 as wide as the screen wall1.height = 200; // Make wall1 taller horizontally game.addChild(wall1); // 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.width / 2; wall1.y = y - wall1.height / 2; } game.move = function (x, y, obj) { if (obj === wall1) { wall1.x = x - wall1.width / 2; wall1.y = y - wall1.height / 2; } }; };
===================================================================
--- original.js
+++ change.js
@@ -94,5 +94,11 @@
if (obj === wall1) {
wall1.x = x - wall1.width / 2;
wall1.y = y - wall1.height / 2;
}
+ game.move = function (x, y, obj) {
+ if (obj === wall1) {
+ wall1.x = x - wall1.width / 2;
+ wall1.y = y - wall1.height / 2;
+ }
+ };
};
\ No newline at end of file