Hello. I have an error in my game, “Balloon Bust” and I would like some help. One problem is that sometimes when you try to pop one balloon, all of the balloons pop. Another problem is when there’s one balloon left, and you try to pop it, an error shows up in the output section.
This is the code:
--# Main
-- Balloon Bust
-- Use this function to perform your initial setup
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
function setup()
balloons = {balloon(5),balloon(7),balloon(3)}
loaded = true
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(0, 183, 255, 255)
-- This sets the line thickness
strokeWidth(5)
-- Do your drawing here
for i,b in ipairs(balloons) do
fill(b.colour)
ellipse(b.pos.x,b.pos.y,b.size)
b.pos.y = b.pos.y + 2
end
if CurrentTouch.state ~= ENDED then
if loaded == true then
loaded = false
tween.delay(1,function() loaded = true end)
local vt = vec2(CurrentTouch.x,CurrentTouch.y)
for i = #balloons, 1, -1 do
if vt:dist(balloons[i].pos) < balloons[i].size then
balloons[i] = nil
end
end
end
end
end
function touched(t)
end
function balloon(s,x,y)
local colors = {color(31, 84, 45, 200),color(245, 0, 255, 200),color(255, 0, 133, 200),color(0, 255, 159, 200),color(0, 0, 0, 200)}
return {size = s*30, colour = colors[math.random(1,#colors)], pos = vec2(x or math.random(0,WIDTH),y or 0)}
end