Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Count and display the number of eaten boxes
User prompt
Count and display the number of eaten boxes
User prompt
Migrate to the latest version of LK
User prompt
slowly increase the number of boxes generated over time
User prompt
Increase the number of boxes generated over time
User prompt
When the pig eats the box, it will also destroy a box in the scene.
User prompt
When the pig eats the box, it will also destroy a boxes in the scene.
User prompt
When the pig eats the box, it will also destroy the a boxes in the scene.
User prompt
The number of boxes generated will increase over time
User prompt
Box generation speed will become faster over time
User prompt
When the pig eats the box, it will also destroy the two boxes in the scene.
User prompt
When the pig eats the box, all the boxes will retreat outside the scene.
User prompt
When the pig eats 10 boxes, it will become larger. The upper limit is 500*500.
User prompt
The box takes priority to the grass position
User prompt
Box movement slows down outside grass
User prompt
When a pig eats a box, a new grass is generated
User prompt
pig cannot eat boxes outside the grass
User prompt
When the box reaches the center, the game ends
User prompt
Let glider follow the mouse hover position
User prompt
Let glider follow the mouse hover position
User prompt
Let glider follow the mouse hover position
User prompt
The pig needs to eat 100 boxes to reach the size of 502*502
User prompt
When the pig exceeds the size of 500*500, the game ends
===================================================================
--- original.js
+++ change.js
@@ -170,17 +170,16 @@
break;
}
}
if (isInsideGrass) {
- box.destroy();
- boxes.splice(index, 1);
- // Increase the counter for the number of boxes eaten by the pig
- pig.boxesEaten = (pig.boxesEaten || 0) + 1;
- // If the pig has eaten 10 boxes, increase its size
- if (pig.boxesEaten % 10 === 0) {
- pig.scale.x = Math.min(pig.scale.x + 0.1, 5); // limit the size to 500x500
- pig.scale.y = Math.min(pig.scale.y + 0.1, 5); // limit the size to 500x500
- }
+ // When the pig eats the box, all the boxes will retreat outside the scene.
+ boxes.forEach(function (box, index) {
+ var angle = Math.random() * Math.PI * 2;
+ var x = 1024 + Math.cos(angle) * 1366;
+ var y = 1366 + Math.sin(angle) * 1366;
+ box.x = x;
+ box.y = y;
+ });
// Generate a new grass at a random position
var newGrass = game.addChild(new Grass());
newGrass.x = Math.random() * 2048; // Random position horizontally
newGrass.y = Math.random() * 2732; // Random position vertically