Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Make coin 1-7 position code for each
User prompt
Add position of each coin in the code
User prompt
center the coins
User prompt
If i hold on the coin and move the cursor move the coin with it
User prompt
Don't random the coins positions
User prompt
Add drag by click on the coin
User prompt
Add the 7 coins to the game
User prompt
Set the background behind all objects
User prompt
increase size of the coins and make it inside the screen not outside the boundaries.
User prompt
add 7 coins with random position in the screen.
User prompt
Add coin assets to get collected by cursor on the screen
User prompt
if i hold after click then move the cursor draw a line or draw by point continuously.
User prompt
add speed to the point
User prompt
if i hold on the screen and point point. Track the click to put the point.
User prompt
fit it to screen
User prompt
Add background
User prompt
Don't expand the point just paint a line
User prompt
Make a point asset for cursor when it's moving expand the point to draw a line.
User prompt
Please fix the bug: 'LK.Graphics is not a constructor' in or related to this line: 'var path = new LK.Graphics();' Line Number: 19
User prompt
Make the mouse the player in this game. If i click and move the cursor paint a color following the movement of the cursor.
User prompt
Remove maze
User prompt
Remove player and its movment from game
User prompt
If i click and hold on the player object in the screen and moved it make the player move with it smoothly.
/**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Create a point asset for the cursor 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 / 1000 }); game.addChildAt(background, 0); background.x = 2048 / 2; background.y = 2732 / 2; game.down = function (x, y, obj) { // Check if the mouse is down game.isMouseDown = true; // Check for intersection with coin assets game.children.forEach(function (child) { if (child.id === 'coin' && point.intersects(child)) { // Set the coin asset to be dragged game.draggedCoin = child; } }); }; // Create 7 new coin assets at fixed positions for (var i = 0; i < 7; i++) { var newCoin = LK.getAsset('coin', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); game.addChild(newCoin); // Set the coins at fixed positions if (i === 0) { newCoin.x = 1035; newCoin.y = 370; } else if (i === 1) { newCoin.x = 400; newCoin.y = 400; } else if (i === 2) { newCoin.x = 600; newCoin.y = 600; } else if (i === 3) { newCoin.x = 800; newCoin.y = 800; } else if (i === 4) { newCoin.x = 1000; newCoin.y = 1000; } else if (i === 5) { newCoin.x = 1200; newCoin.y = 1200; } else if (i === 6) { newCoin.x = 1400; newCoin.y = 1400; } 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) { // Set a flag to track if the mouse is up game.isMouseDown = false; }; game.move = function (x, y, obj) { // Check if the mouse is down if (game.isMouseDown) { // Create a new point asset at the current mouse position var newPoint = LK.getAsset('point', { anchorX: 0.5, anchorY: 0.5 }); game.addChild(newPoint); newPoint.x = x; newPoint.y = y; // Add speed to the point newPoint.speed = 5; // Check for intersection with coin assets game.children.forEach(function (child) { if (child.id === 'coin' && newPoint.intersects(child)) { // Remove the coin asset from the game game.removeChild(child); } }); } };
===================================================================
--- original.js
+++ change.js
@@ -46,10 +46,10 @@
});
game.addChild(newCoin);
// Set the coins at fixed positions
if (i === 0) {
- newCoin.x = 600;
- newCoin.y = 200;
+ newCoin.x = 1035;
+ newCoin.y = 370;
} else if (i === 1) {
newCoin.x = 400;
newCoin.y = 400;
} else if (i === 2) {