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
@@ -4,12 +4,11 @@
//<Assets used in the game will automatically appear here>
// Balloon class
var Balloon = Container.expand(function () {
var self = Container.call(this);
- var colors = [0x00ff00, 0x0000ff, 0xffff00, 0xff00ff];
+ var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff];
var color = colors[Math.floor(Math.random() * colors.length)];
- var assetId = color === 0xff0000 ? 'explodingBalloon' : 'balloon';
- var balloonGraphics = self.attachAsset(assetId, {
+ var balloonGraphics = self.attachAsset('balloon', {
width: 100,
height: 150,
color: color,
shape: 'ellipse',
@@ -23,9 +22,9 @@
self.destroy();
}
};
self.down = function (x, y, obj) {
- if (assetId === 'explodingBalloon') {
+ if (color === 0xff0000) {
// Red balloon explodes
explode(self.x, self.y);
} else {
// Other balloons just pop
@@ -124,8 +123,10 @@
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);
}
}
// Update spikes
@@ -157,12 +158,10 @@
y: y
})) {
balloons[i].down(x, y, obj);
balloons.splice(i, 1);
- if (balloons[i].assetId !== 'explodingBalloon') {
- score++;
- scoreTxt.setText(score);
- }
+ score++;
+ scoreTxt.setText(score);
break;
}
}
};
\ No newline at end of file