User prompt
create more walls of wall2 to make it hard a bit.
User prompt
recreate the maze again with wall2 in the space between 4 walls of wall1.
User prompt
let the touch of any coin increase the scoretxt by 1 not 2 to be 7/7 on the final.
Code edit (1 edits merged)
Please save this source code
User prompt
make the wall2 can be dragged by curos
User prompt
Add logic of cursor to drag wall2 by click on it.
User prompt
Add logic to drag by click for the wall2
User prompt
Drag the wall2 if the cursor reach any walls of wall2.
User prompt
Add collision to the wall1 and wall2
User prompt
If the mouse button clicked while cursor in position of wall2 drag the wall by cursor.
User prompt
If the mouse button is down in any walls of wall2 hold the wall with cursor and track its movement till release the mouse button.
User prompt
add drag by cursor for the wall2
User prompt
add drag logic for wall2 by cursor
User prompt
random the shapes and the positions make shapes with 2 or 3 walls.
User prompt
make it more difficult maze
User prompt
can you add more walls and generate a maze in side the 4 walls of wall1.
User prompt
add wall2 walls like 5 thin and large and small horizontal and other 5 same size vertical.
User prompt
create wall2
User prompt
Make the top wall thick vertically
User prompt
Add another wall of wall1 for the right and left and top sides
User prompt
lower it
User prompt
make it talltill the pause button only
User prompt
Make it with same size of the background right side.
User prompt
make it tall as the side of the image not tall to the top.
User prompt
add wall1 for the right side of the image background1 make it tall vertical as the size of the right side of the background1.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 3 }); self.touchCount = 0; // Add a counter to track the number of times the coin has been touched self.lastWasIntersecting = false; // Initialize lastWasIntersecting for tracking intersection state // Add rotation to the coin continuously when the game start self.update = function () { if (self.touchCount === 0) { self.rotation += 0.05; } // Check if the point reaches the coin if (!self.lastWasIntersecting && (point.intersects(self) || Math.abs(point.x - self.x) <= self.width / 2 && Math.abs(point.y - self.y) <= self.height / 2)) { // Increase the touch count self.touchCount++; // Play a sound effect LK.getSound('coin').play(); // Add score (only adds 1 point) LK.setScore(LK.getScore() + 1); // Update the score display to show the number of coins after a slash scoreTxt.setText(LK.getScore() + '/7'); // Remove the coin from the game after it's been touched self.destroy(); } self.lastWasIntersecting = point.intersects(self) || Math.abs(point.x - self.x) <= self.width / 2 && Math.abs(point.y - self.y) <= self.height / 2; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Create and position the wall1 asset at the bottom of the screen var wall1 = LK.getAsset('wall1', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, // Scale to fit the width of the screen scaleY: 1 // Keep the original height }); wall1.x = 2048 / 2; // Center horizontally wall1.y = 2732 - wall1.height / 2; // Position at the bottom game.addChild(wall1); // Create and position the wall1 asset at the top of the screen var wallTop = LK.getAsset('wall1', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, // Scale to fit the width of the screen scaleY: 3 // Increase the vertical thickness }); wallTop.x = 2048 / 2; // Center horizontally wallTop.y = wallTop.height / 2; // Position at the top game.addChild(wallTop); // Create and position the wall1 asset at the left side of the screen var wallLeft = LK.getAsset('wall1', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, // Keep the original width scaleY: 2732 / 100 // Scale to fit the height of the screen }); wallLeft.x = wallLeft.width / 2; // Position at the left wallLeft.y = 2732 / 2; // Center vertically game.addChild(wallLeft); // Create right wall1 once var wallRight = LK.getAsset('wall1', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, // Keep the original width scaleY: 2732 / 100 // Scale to fit the height of the screen }); wallRight.x = 2048 - wallRight.width / 2; // Position at the right wallRight.y = 2732 / 2; // Center vertically game.addChild(wallRight); // Create and position wall2 assets to form a maze inside the 4 main walls // Calculate playable area dimensions var playableAreaLeft = wallLeft.width; var playableAreaRight = 2048 - wallRight.width; var playableAreaTop = wallTop.height; var playableAreaBottom = 2732 - wall1.height; var playableWidth = playableAreaRight - playableAreaLeft; var playableHeight = playableAreaBottom - playableAreaTop; // Create vertical wall2 assets in the maze var verticalCount = 6; var horizontalCount = 5; var spacingX = playableWidth / (verticalCount + 1); var spacingY = playableHeight / (horizontalCount + 1); // Add vertical walls for (var i = 0; i < verticalCount; i++) { var verticalWall = LK.getAsset('wall2', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: Math.random() * 4 + 3 // Random scale between 3-7 }); verticalWall.x = playableAreaLeft + spacingX * (i + 1); verticalWall.y = playableAreaTop + playableHeight / 2 + (Math.random() * 0.6 - 0.3) * playableHeight; // Random Y position within middle 60% of playable area game.addChild(verticalWall); } // Add horizontal walls for (var i = 0; i < horizontalCount; i++) { var horizontalWall = LK.getAsset('wall2', { anchorX: 0.5, anchorY: 0.5, scaleX: Math.random() * 4 + 3, // Random scale between 3-7 scaleY: 0.8 // Thin wall }); horizontalWall.x = playableAreaLeft + playableWidth / 2 + (Math.random() * 0.6 - 0.3) * playableWidth; // Random X position within middle 60% of playable area horizontalWall.y = playableAreaTop + spacingY * (i + 1); game.addChild(horizontalWall); } var point = LK.getAsset('point', { anchorX: 0.5, anchorY: 0.5 }); game.addChild(point); // Handle mouse movement // Add background to the game var background = LK.getAsset('Background1', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 1000, scaleY: 2732 / 1075 }); game.addChildAt(background, 0); background.x = 2048 / 2; background.y = 2732 / 2 + 115; // Lower the background a bit from the top game.down = function (x, y, obj) { // Check if a wall2 asset is being clicked game.children.forEach(function (child) { if (child.assetId === 'wall2' && child.intersects(point)) { game.draggedWall = child; } }); // Set a flag to track if the mouse is down game.isMouseDown = true; // Coin handling is now done exclusively in the Coin class update method }; // Create 7 new coin assets at fixed positions for (var i = 0; i < 7; i++) { var newCoin = new Coin(); game.addChild(newCoin); // Set the coins at fixed positions if (i === 0) { newCoin.x = 1035; newCoin.y = 550; } else if (i === 1) { newCoin.x = 775; newCoin.y = 790; } else if (i === 2) { newCoin.x = 640; newCoin.y = 1485; } else if (i === 3) { newCoin.x = 1685; newCoin.y = 670; } else if (i === 4) { newCoin.x = 640; newCoin.y = 1840; } else if (i === 5) { newCoin.x = 365; newCoin.y = 1425; } else if (i === 6) { newCoin.x = 1815; newCoin.y = 1425; } else { newCoin.x = 200 + i * 200; newCoin.y = 200 + i * 200; } console.log("Coin " + (i + 1) + " position: x=" + newCoin.x + ", y=" + newCoin.y); } game.up = function (x, y, obj) { // Reset the dragged wall when the mouse is released game.draggedWall = null; game.isMouseDown = false; // Set a flag to track if the mouse is up game.isMouseDown = false; // Reset the dragged wall when the mouse is released game.draggedWall = null; // Set a flag to track if the mouse is up game.isMouseDown = false; }; // Set a flag to track if the mouse is up game.isMouseDown = false; // Add level text to the top right side var levelText = new Text2('Level 1', { size: 100, fill: 0xFFFFFF }); levelText.anchor.set(1, 0); // Sets anchor to the top right edge of the text. LK.gui.topRight.addChild(levelText); // Initialize status time var statusTime = 60; // 60 seconds = 1 minute // Initialize status time text var statusTimeText = new Text2(statusTime.toString(), { size: 100, fill: 0xFFFFFF }); // Initialize score text to display the number of coins after a slash var scoreTxt = new Text2('0/7', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.8, 0); // Sets anchor to the top center edge of the text. LK.gui.top.addChild(scoreTxt); statusTimeText.anchor.set(-0.8, 0); // Sets anchor to the top center edge of the text. LK.gui.top.addChild(statusTimeText); // Create a timer that decreases the status time every second var statusTimeTimer = LK.setInterval(function () { statusTime--; // Update the status time text statusTimeText.setText(statusTime.toString()); // If the status time reaches 0, stop the timer and show game over if (statusTime <= 0) { LK.clearInterval(statusTimeTimer); LK.showGameOver(); } // Update the score text position to be beside the status time text scoreTxt.x = statusTimeText.x - statusTimeText.width / 2 - scoreTxt.width / 2 - 50; // Add some space between the status coin text and the time }, 1000); // 1000 milliseconds = 1 second // Update the score display to show the number of coins after a slash scoreTxt.setText(LK.getScore() + '/7'); game.move = function (x, y, obj) { // Check if the mouse is down and a wall2 asset is being dragged if (game.isMouseDown && game.draggedWall) { game.draggedWall.x = x; game.draggedWall.y = y; } else { // Check if the cursor reaches any wall2 asset game.children.forEach(function (child) { if (child.assetId === 'wall2' && point.intersects(child)) { game.draggedWall = child; } }); } // Update the position of the point asset to the current mouse position point.x = x; point.y = y; // Draw the way of cursor by point asset when its moving var newPoint = LK.getAsset('point', { anchorX: 0.5, anchorY: 0.5 }); newPoint.x = x; newPoint.y = y; game.addChild(newPoint); // Check for intersection with wall1 and wall2 assets game.children.forEach(function (child) { if ((child.assetId === 'wall1' || child.assetId === 'wall2') && point.intersects(child)) { // Handle collision with wall1 or wall2 console.log("Collision detected with wall:", child.assetId); // Implement any specific logic needed for collision with walls } }); // Coin collision is now handled in the Coin class update method // We don't need to check for coin collisions here anymore };
===================================================================
--- original.js
+++ change.js
@@ -80,47 +80,55 @@
});
wallLeft.x = wallLeft.width / 2; // Position at the left
wallLeft.y = 2732 / 2; // Center vertically
game.addChild(wallLeft);
-// Create and position vertical wall2 assets to form a maze
-var verticalPositions = [300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900];
-var verticalScales = [5, 3, 4, 6, 3, 5, 4, 6, 5];
-for (var i = 0; i < verticalPositions.length; i++) {
+// Create right wall1 once
+var wallRight = LK.getAsset('wall1', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ // Keep the original width
+ scaleY: 2732 / 100 // Scale to fit the height of the screen
+});
+wallRight.x = 2048 - wallRight.width / 2; // Position at the right
+wallRight.y = 2732 / 2; // Center vertically
+game.addChild(wallRight);
+// Create and position wall2 assets to form a maze inside the 4 main walls
+// Calculate playable area dimensions
+var playableAreaLeft = wallLeft.width;
+var playableAreaRight = 2048 - wallRight.width;
+var playableAreaTop = wallTop.height;
+var playableAreaBottom = 2732 - wall1.height;
+var playableWidth = playableAreaRight - playableAreaLeft;
+var playableHeight = playableAreaBottom - playableAreaTop;
+// Create vertical wall2 assets in the maze
+var verticalCount = 6;
+var horizontalCount = 5;
+var spacingX = playableWidth / (verticalCount + 1);
+var spacingY = playableHeight / (horizontalCount + 1);
+// Add vertical walls
+for (var i = 0; i < verticalCount; i++) {
var verticalWall = LK.getAsset('wall2', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 0.5,
- // Thin wall
- scaleY: verticalScales[i] // Varying size
+ scaleX: 0.8,
+ scaleY: Math.random() * 4 + 3 // Random scale between 3-7
});
- verticalWall.x = verticalPositions[i];
- verticalWall.y = 2732 / 2; // Center vertically
+ verticalWall.x = playableAreaLeft + spacingX * (i + 1);
+ verticalWall.y = playableAreaTop + playableHeight / 2 + (Math.random() * 0.6 - 0.3) * playableHeight; // Random Y position within middle 60% of playable area
game.addChild(verticalWall);
}
-// Create and position horizontal wall2 assets to form a maze
-var horizontalPositions = [400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000];
-var horizontalScales = [4, 3, 5, 4, 3, 6, 3, 5, 4];
-for (var i = 0; i < horizontalPositions.length; i++) {
- var wallRight = LK.getAsset('wall1', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1,
- // Keep the original width
- scaleY: 2732 / 100 // Scale to fit the height of the screen
- });
- wallRight.x = 2048 - wallRight.width / 2; // Position at the right
- wallRight.y = 2732 / 2; // Center vertically
- game.addChild(wallRight);
- // Create and position five horizontal wall2 assets
+// Add horizontal walls
+for (var i = 0; i < horizontalCount; i++) {
var horizontalWall = LK.getAsset('wall2', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: horizontalScales[i],
- // Varying size
- scaleY: 0.5 // Thin wall
+ scaleX: Math.random() * 4 + 3,
+ // Random scale between 3-7
+ scaleY: 0.8 // Thin wall
});
- horizontalWall.x = 2048 / 2; // Center horizontally
- horizontalWall.y = horizontalPositions[i];
+ horizontalWall.x = playableAreaLeft + playableWidth / 2 + (Math.random() * 0.6 - 0.3) * playableWidth; // Random X position within middle 60% of playable area
+ horizontalWall.y = playableAreaTop + spacingY * (i + 1);
game.addChild(horizontalWall);
}
var point = LK.getAsset('point', {
anchorX: 0.5,
@@ -144,11 +152,8 @@
if (child.assetId === 'wall2' && child.intersects(point)) {
game.draggedWall = child;
}
});
- game.isMouseDown = true;
- game.isMouseDown = true;
- game.isMouseDown = true;
// Set a flag to track if the mouse is down
game.isMouseDown = true;
// Coin handling is now done exclusively in the Coin class update method
};