// Project: Balloon POP
// Created: 2022-10-25
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Balloon POP" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
Type tBalloon
ID as integer
Time
YPos
XPos
Frame
visible
UnderTheLine
Speed
SpriteFrame
Animation
HitTest
GetFrame
endtype
global All_Balloons as tBalloon[]
global Balloons as tBalloon
BackGroundPick=random(1,6)
BackGround=LoadSprite("background-"+STR(BackGroundPick)+".PNG")
//BackGround=LoadSprite("background-2.PNG")
for A=1 to 5
Balloons.ID=LoadSprite("Ballons.png")
SetSpriteAnimation(Balloons.ID,256,256,24)
SetSpritePositionByOffset(Balloons.ID,random(10,750),0)
size=random(60,90)
SetSpriteSize( Balloons.ID, size, size )
Balloons.GetFrame=random(1,6)
if Balloons.GetFrame=1 then SetSpriteFrame(Balloons.ID,1)
if Balloons.GetFrame=2 then SetSpriteFrame(Balloons.ID,5)
if Balloons.GetFrame=3 then SetSpriteFrame(Balloons.ID,9)
if Balloons.GetFrame=4 then SetSpriteFrame(Balloons.ID,13)
if Balloons.GetFrame=5 then SetSpriteFrame(Balloons.ID,17)
if Balloons.GetFrame=6 then SetSpriteFrame(Balloons.ID,21)
Balloons.Speed=random(1,5)
All_Balloons.Insertsorted(Balloons)
next A
Collected=0
ang=0
BalloonSpeed=1
CreateText(1,"Collected")
SetTextSize(1,50)
SetTextPosition(1,10,10)
sound_1 = LoadSound("BombExplode.wav")
sound_2 = LoadSound("playerDie.wav")
Music_1=LoadMusic("music.mp3")
SetMusicFileVolume( 1, 50 )
PlayMusic(1)
do
for A=All_Balloons.length to 0 Step -1
mx#=ScreenToWorldX(GetPointerX())
my#=ScreenToWorldY(GetPointerY())
if getpointerpressed()=1
All_Balloons[A].HitTest = GetSpriteHitTest (All_Balloons[A].ID, mx#, my# )
//click offset
ox# = mx# - GetSpriteXbyoffset ( All_Balloons[A].ID )
oy# = my# - GetSpriteYbyoffset ( All_Balloons[A].ID )
endif
if getpointerreleased()=1
All_Balloons[A].HitTest = 0
endif
All_Balloons[A].Frame=GetSpriteCurrentFrame( All_Balloons[A].ID )
All_Balloons[A].YPos=GetSpriteYByOffset(All_Balloons[A].ID)
if All_Balloons[A].YPos>100 and getpointerpressed() = 1 and All_Balloons[A].HitTest=1 then All_Balloons[A].Animation=1
if All_Balloons[A].Animation=1
if All_Balloons[A].Frame=1 then PlaySprite(All_Balloons[A].ID,5.0,0,1,4)
if All_Balloons[A].Frame=5 then PlaySprite(All_Balloons[A].ID,5.0,0,5,8)
if All_Balloons[A].Frame=9 then PlaySprite(All_Balloons[A].ID,5.0,0,9,12)
if All_Balloons[A].Frame=13 then PlaySprite(All_Balloons[A].ID,5.0,0,13,16)
if All_Balloons[A].Frame=17 then PlaySprite(All_Balloons[A].ID,5.0,0,17,20)
if All_Balloons[A].Frame=21 then PlaySprite(All_Balloons[A].ID,5.0,0,21,24)
PlaySound(sound_1,100,0,0)
All_Balloons[A].Time=-300
All_Balloons[A].XPos=random(10,750)
All_Balloons[A].Speed=5
All_Balloons[A].Animation=0
else
inc All_Balloons[A].Time,All_Balloons[A].Speed
inc ang, 1
if All_Balloons[A].Time>100 then SetSpritePositionByOffset(All_Balloons[A].ID,All_Balloons[A].XPos,All_Balloons[A].Time)
SetSpriteAngle(All_Balloons[A].ID,ang)
endif
if All_Balloons[A].Frame=4 then SetSpriteVisible(All_Balloons[A].ID,0)
if All_Balloons[A].Frame=8 then SetSpriteVisible(All_Balloons[A].ID,0)
if All_Balloons[A].Frame=12 then SetSpriteVisible(All_Balloons[A].ID,0)
if All_Balloons[A].Frame=16 then SetSpriteVisible(All_Balloons[A].ID,0)
if All_Balloons[A].Frame=20 then SetSpriteVisible(All_Balloons[A].ID,0)
if All_Balloons[A].Frame=24 then SetSpriteVisible(All_Balloons[A].ID,0)
if All_Balloons[A].Time=205 then All_Balloons[A].visible=1
if All_Balloons[A].visible=1
SetSpriteVisible(All_Balloons[A].ID,1)
All_Balloons[A].GetFrame=random(1,6)
if All_Balloons[A].GetFrame=1 then SetSpriteFrame(All_Balloons[A].ID,1)
if All_Balloons[A].GetFrame=2 then SetSpriteFrame(All_Balloons[A].ID,5)
if All_Balloons[A].GetFrame=3 then SetSpriteFrame(All_Balloons[A].ID,9)
if All_Balloons[A].GetFrame=4 then SetSpriteFrame(All_Balloons[A].ID,13)
if All_Balloons[A].GetFrame=5 then SetSpriteFrame(All_Balloons[A].ID,17)
if All_Balloons[A].GetFrame=6 then SetSpriteFrame(All_Balloons[A].ID,21)
size=random(50,110)
SetSpriteSize( All_Balloons[A].ID, size, size )
All_Balloons[A].visible=0
endif
if All_Balloons[A].YPos=800 and All_Balloons[A].UnderTheLine=0 then All_Balloons[A].UnderTheLine=1
if All_Balloons[A].UnderTheLine=1
All_Balloons[A].Time=-300
All_Balloons[A].XPos=random(10,750)
SetSpritePositionByOffset(All_Balloons[A].ID,All_Balloons[A].XPos,30)
Collected=Collected-1
PlaySound(sound_2,30,0,0)
All_Balloons[A].UnderTheLine=0
endif
if All_Balloons[A].YPos>100 and GetPointerPressed() = 1 and All_Balloons[A].HitTest=1 then Collected=Collected+1
if All_Balloons[A].Time>800 then All_Balloons[A].Time=-300
SetTextString ( 1, line0$ )
line0$ = "Collected (" + str (Collected ) +")"
next A
Sync()
loop