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
@@ -103,13 +103,8 @@
/****
* Game Code
****/
-var eatenBoxesTxt = new Text2('Eaten Boxes: 0', {
- size: 50,
- fill: "#ffffff"
-});
-LK.gui.top.addChild(eatenBoxesTxt);
var glider = game.addChild(new Glider());
var pig = game.addChild(new Pig());
pig.x = glider.x + 200; // Start 200 pixels to the right of the glider
pig.y = glider.y; // Start at the same vertical position as the glider
@@ -141,9 +136,14 @@
dragNode = null;
});
// Array to hold box objects
var boxes = [];
-var eatenBoxes = 0;
+var boxesEaten = 0;
+var boxesEatenTxt = new Text2('Boxes Eaten: 0', {
+ size: 50,
+ fill: "#ffffff"
+});
+LK.gui.top.addChild(boxesEatenTxt);
// Game tick event
LK.on('tick', function () {
// Update glider, pig, stars, and obstacles
glider._update_migrated();
@@ -178,10 +178,10 @@
}
if (isInsideGrass) {
box.destroy();
boxes.splice(index, 1);
- eatenBoxes++;
- eatenBoxesTxt.setText('Eaten Boxes: ' + eatenBoxes);
+ boxesEaten++;
+ boxesEatenTxt.setText('Boxes Eaten: ' + boxesEaten);
// 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