User prompt
Modify the name of the game to "Jungle Battle".
User prompt
Use the asset BGM as the background music with a soft volume and make it a bit quieter.
User prompt
Every time the arrow asset is shot out, it will be accompanied by the sound effect of the projectile asset.
User prompt
Change the text display of "Arrows" on the arrow counter to "Bananas", but its function remains the same and it can still count as before.
User prompt
After changing the quantity and eliminating the orangutan asset, the quantity of arrows will be increased by 5 and counted into the total amount.
User prompt
Add an animation effect for the orangutan asset. After the orangutan disappears, some special effects similar to energy will appear. These energy effects will fly to the position of the arrow counter and then disappear. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add that after eliminating the orangutan asset, the quantity of arrows will be increased by 4 and counted into the total amount
User prompt
Delete the words "Recharging".
User prompt
If the arrow counter shows 0, a reminder with the words "Recharging" will appear below the counter. When the arrow has a value again, this reminder will disappear.
User prompt
Enlarge and bold the words of the arrow counter, and use a striking red color for it.
User prompt
Place the arrow counter at the right side of the screen.
User prompt
Change the way arrows appear. After clicking, an arrow projectile will be launched towards the monsters. However, there is a quantity limit. The maximum quantity is 10. After shooting 10 arrows, it needs to cool down and wait for 2 seconds to recharge and restore to the value of 10. Moreover, an arrow counter also needs to be made to record the usage of arrows.
User prompt
Add the orangutan asset. Randomly refresh one orangutan asset 5 seconds after the game starts. They will appear at the edge of the map and rush towards the archers. Moreover, the refreshing of the orangutan asset will be repeated every 5 seconds until the game ends.
User prompt
Check whether an excessive number of arrow assets will cause the game to lag.
User prompt
Check the code for the asset arrow to see if rapid clicking will cause lagging.
User prompt
Check the code. There will be lagging about 30 seconds after the game starts.
User prompt
Don't refresh orangutan assets.
User prompt
The game is experiencing lag. Optimize the lag issue.
User prompt
Thirty seconds after the game starts, the frequency of refreshing monster assets will increase by 30 percent.
User prompt
The score obtained after eliminating the orangutan will be multiplied by 2 on the basis of the original score.
User prompt
After the gorilla appears for the first time, it will reappear every 5 seconds and repeat this process until the end of the game.
User prompt
Change the way the gorilla asset appears. Instead of appearing after eliminating 10 monsters, it will be changed to randomly refresh one or two gorilla assets 5 seconds after the game starts. They will appear at the edge of the map and rush towards the archers.
User prompt
Design another asset named "Gorilla". Whenever ten monster assets are eliminated, a gorilla will be randomly spawned at the edge of the map. Just like the monsters, it will also rush towards the "Archer" asset. Once the gorilla touches the "Archer" asset, the game will end as well. It can also be eliminated by the "Arrow" asset, but it must be touched by the arrows five times before it can be eliminated.
User prompt
Design a score counter. Ten points will be obtained whenever a single arrow eliminates a monster.
User prompt
Set an asset as the background.
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Arrow class var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('Arrow', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.direction = { x: 0, y: 0 }; self.update = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; for (var i = monsters.length - 1; i >= 0; i--) { if (self.intersects(monsters[i])) { if (monsters[i] instanceof Gorilla) { monsters[i].hitCount++; if (monsters[i].hitCount >= 5) { monsters[i].destroy(); monsters.splice(i, 1); // Update score score += 20; scoreText.setText('Score: ' + score); // Increase arrow count by 5 arrowCount += 5; arrowCountText.setText('Arrows: ' + arrowCount); } } else { monsters[i].destroy(); monsters.splice(i, 1); // Update score score += 10; scoreText.setText('Score: ' + score); } self.destroy(); return; } } }; }); var Gorilla = Container.expand(function () { var self = Container.call(this); var gorillaGraphics = self.attachAsset('Gorilla', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.direction = { x: 0, y: 0 }; self.hitCount = 0; self.update = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; }; }); // Monster class var Monster = Container.expand(function () { var self = Container.call(this); var monsterGraphics = self.attachAsset('Monster', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.direction = { x: 0, y: 0 }; self.update = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000, name: 'Jungle Battle' }); /**** * Game Code ****/ LK.playMusic('BGM'); var background = game.addChild(LK.getAsset('Background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); var archer = game.addChild(LK.getAsset('Archer', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); var monsters = []; game.update = function () { if (LK.ticks < 1800 && LK.ticks % 120 == 0 || LK.ticks >= 1800 && LK.ticks % 84 == 0) { var monster = game.addChild(new Monster()); var spawnSide = Math.floor(Math.random() * 4); switch (spawnSide) { case 0: // top monster.x = Math.random() * 2048; monster.y = 0; break; case 1: // right monster.x = 2048; monster.y = Math.random() * 2732; break; case 2: // bottom monster.x = Math.random() * 2048; monster.y = 2732; break; case 3: // left monster.x = 0; monster.y = Math.random() * 2732; break; } var dx = archer.x - monster.x; var dy = archer.y - monster.y; var magnitude = Math.sqrt(dx * dx + dy * dy); monster.direction.x = dx / magnitude; monster.direction.y = dy / magnitude; monsters.push(monster); } if (LK.ticks % 300 == 0) { var orangutan = game.addChild(new Gorilla()); orangutan.x = Math.random() * 2048; orangutan.y = 0; var dx = archer.x - orangutan.x; var dy = archer.y - orangutan.y; var magnitude = Math.sqrt(dx * dx + dy * dy); orangutan.direction.x = dx / magnitude; orangutan.direction.y = dy / magnitude; monsters.push(orangutan); } for (var i = monsters.length - 1; i >= 0; i--) { if (monsters[i].intersects(archer)) { LK.showGameOver(); } } }; // Initialize score var score = 0; // Initialize arrow count var arrowCount = 10; // Create score text var scoreText = new Text2('Score: 0', { size: 50, fill: 0xFFFFFF }); // Initialize last arrow shot time var lastArrowShotTime = 0; scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Create arrow count text var arrowCountText = new Text2('Arrows: 10', { size: 100, fill: 0xFF0000, fontWeight: 'bold' }); arrowCountText.anchor.set(1, 0); LK.gui.topRight.addChild(arrowCountText); // Create recharging reminder var rechargeText = new Text2('Recharging', { size: 80, fill: 0xFF0000, fontWeight: 'bold' }); rechargeText.anchor.set(1, 0); rechargeText.y = arrowCountText.height; // Position it below the arrow count text rechargeText.visible = false; // Hide it initially LK.gui.topRight.addChild(rechargeText); game.down = function (x, y, obj) { // Check if the last arrow was fired less than 100ms ago if (this.lastArrowTime && Date.now() - this.lastArrowTime < 100) { return; } // Check if there are any arrows left if (arrowCount <= 0) { // Check if 2 seconds have passed since the last arrow was shot if (Date.now() - lastArrowShotTime >= 2000) { // Recharge the arrows arrowCount = 10; arrowCountText.setText('Arrows: ' + arrowCount); } return; } this.lastArrowTime = Date.now(); var arrow = game.addChild(new Arrow()); arrow.x = archer.x; arrow.y = archer.y; var dx = x - archer.x; var dy = y - archer.y; var magnitude = Math.sqrt(dx * dx + dy * dy); arrow.direction.x = dx / magnitude; arrow.direction.y = dy / magnitude; // Decrease the arrow count and update the text arrowCount--; arrowCountText.setText('Bananas: ' + arrowCount); // If all arrows have been shot, store the time if (arrowCount == 0) { lastArrowShotTime = Date.now(); } // Play the sound effect of the projectile asset LK.getSound('projectile').play(); };
===================================================================
--- original.js
+++ change.js
@@ -82,9 +82,10 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: 0x000000,
+ name: 'Jungle Battle'
});
/****
* Game Code
A single, cartoonish little monster. It has fur and a big mouth, and its movement posture looks as if it's about to pounce forward.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
It's a 2D planar background. It's a jungle with green grass growing all over the ground and thick forests surrounding it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An orangutan in a cartoon image.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bunch of bananas in a cartoon image.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.