User prompt
every 30 seconds, spawn slightly more balloons
User prompt
a balloon is missed if it makes it off the top of the screen
User prompt
players lose a point for every balloon missed
User prompt
if a balloon is not popped and reaches the top of the player's screen, then the game ends
User prompt
balloons that can explode are a different color
User prompt
every balloon popped is a point earned
User prompt
if a balloon explodes, it launches spikes in random directions that can pop other balloons
User prompt
Please fix the bug: 'Uncaught TypeError: balloons[i].containsPoint is not a function' in or related to this line: 'if (balloons[i].containsPoint({' Line Number: 113
Initial prompt
Balloon Surprise
===================================================================
--- original.js
+++ change.js
@@ -84,13 +84,21 @@
* Game Code
****/
var balloons = [];
var score = 0;
+var missedBalloons = 0; // Initialize missed balloons counter
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
+var missedTxt = new Text2('Missed: 0', {
+ size: 100,
+ fill: "#ff0000"
+});
+missedTxt.anchor.set(0.5, 0);
+missedTxt.y = 200; // Position below the score text
+LK.gui.top.addChild(missedTxt);
LK.gui.top.addChild(scoreTxt);
function spawnBalloon() {
var balloon = new Balloon();
balloon.x = Math.random() * 2048;
@@ -123,11 +131,13 @@
game.update = function () {
for (var i = balloons.length - 1; i >= 0; i--) {
balloons[i].update();
if (balloons[i].y < -100) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
balloons.splice(i, 1);
+ missedBalloons++; // Increment missed balloons counter
+ score--; // Decrement score when a balloon is missed
+ scoreTxt.setText(score); // Update score text
+ missedTxt.setText('Missed: ' + missedBalloons); // Update missed balloons text
}
}
// Update spikes
var spikes = game.children.filter(function (child) {