This is my first real game that I've made. Its a vertically scrolling 2D shooting game.
Controls:
Movement - Arrow Keys
Fire - control
Pause - P
Unpause - Any key except P
You will need to download the media attached to this post to run the game.
To run the game just change the directory at line 36 to match where the media is on your PC.
here is the code
`--------------------------------------------
`Scott McCabe
`Advanced Higher Project 2006/2007
`Source Code for game
`Project writen in DarkBASIC Professional
`Started on: 23rd October 2006
`Fininshed on: 30th March 2007
`PURPOSE OF PROGRAM: The game is for the Advanced Higher project which must
`include both file handling and sorting. As such this program includes both
`file handling and a bubble sort.
`DESCRIPTION OF PROGRAM: The game is a 2D vertically scrolling shooting game.
`In the game enemies fly towards the player and shoot at the player when the
`player is in range. The player controls their plane with the arrow keys and
`shoots using the control key. The player gets points for shooting enemies
`and when the player health reaches 0 the player looses a life. When there are
`no more lives left the game is over.
`--------------------------------------------
set display mode 1024,768,32
hide mouse
dim sx(22):dim sy(22)
dim jj1x(22):dim jj1y(22)
dim bp1x(22):dim bp1y(22)
dim bp2x(22):dim bp2y(22)
dim bp3x(22):dim bp3y(22)
dim score$(10,1)
name$=""
set text size 20
value=200
set cursor 700,value
schooldir$="h:\Project\Media\"
homedir$="C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\VS\media\"
set dir homedir$
pln$="media\player\"
snd$="Sounds\Military\"
wpn$="media\weapons\"
wpnsnd$="Sounds\Guns\"
enm$="media\enemy\blue\"
xpl$="media\explode\"
`-----------------------------------------------------------------
`-- Loading Screen - completely pointless but cool non-the-less --
`-- REM'ed out because it just slows the program down --
`-----------------------------------------------------------------
remstart
load bitmap "media\time\cabesoft2.jpg",0
loadbox=0
loadtime=-175
boxleft=(screen width()/2)-140
ink rgb(0,255,0),rgb(0,0,0)
set cursor (screen width()/2)-50,625
set text size 30
set text to bolditalic
print "loading"
for x=1 to 3000
wait 1
inc loadbox,1
if loadbox>=30
inc loadtime,3
boxleft=(screen width()/2)+loadtime
box (screen width()/2)-175,(screen height()/2)+280,boxleft,(screen height()/2)+295
loadbox=0
endif
if shiftkey()=1 then goto skip
next x
remend
skip:
CLS
`-------------------------------------
`-- Loads in a highscore table from --
`-- an external file and performs a --
`-- bubble sort to order scores --
`-------------------------------------
set text to normal
set text size 22
scorearray$="highscores.cabe"
if file exist(scorearray$)=1
load array scorearray$,score$()
do
swap=0
for x=1 to 10
scorestr1$=score$(x,1)
scorestr2$=score$(x+1,1)
scoreval1=val(scorestr1$)
scoreval2=val(scorestr2$)
if scoreval2>scoreval1
name1$=score$(x,0)
name2$=score$(x+1,0)
score$(x,0)=name1$
score$(x+1,0)=name2$
score$(x,1)=str$(scoreval2)
score$(x+1,1)=str$(scoreval1)
swap=1
endif
next x
if swap=0 then exit
loop
save array scorearray$,score$()
endif
if file exist(scorearray$)=0
for x = 1 to 10
score$(x,0)="Empty"
scoreval=1000*x
score$(x,1)=str$(scoreval)
next x
save array scorearray$,score$()
endif
`-----------------------------------------------
`-- Displays the sorted score table on screen --
`-----------------------------------------------
do
for x=1 to 10
if x<4
ink rgb(0,255,0),RGB(0,0,0)
endif
if x>=4
ink rgb(255,255,255),RGB(0,0,0)
endif
if x<10
set cursor 600,value
print str$(x)+" -- "+score$(x,0)+" -- "+score$(x,1)
value=value+30
endif
if x=10
set cursor 590,value
print str$(x)+" -- "+score$(x,0)+" -- "+score$(x,1)
value=value+30
endif
next x
value=200
`----------------------------------------------
`-- Displays controls ands scoring on screen --
`----------------------------------------------
set cursor 200,300
set text size 24
set text to bolditalic
print "Controls"
set text to normal
set text size 20
set cursor 200,350
ink RGB(255,50,50),RGB(0,0,0)
print "Fire ";
ink RGB(120,120,255),RGB(0,0,0)
print "- Left Control"
set cursor 200,380
ink RGB(255,50,50),RGB(0,0,0)
print "Movement ";
ink RGB(120,120,255),RGB(0,0,0)
print "- Arrow Keys"
ink RGB(255,255,255),RGB(0,0,0)
load image enm$+"blue2.png",1
paste image 1,200,420
set cursor 230,425
print " - 200 points"
load image pln$+"japjet2.png",2
paste image 2,174,460
set cursor 230,470
print " - 500 points"
set cursor 200,200
set text size 20
input "Please enter your name: ";name$
namelen=len(name$)
if name$=""
cls
set cursor 200,200
ink RGB(255,0,0),RGB(0,0,0)
Print "Please enter a name"
set cursor 200,230
Print "Press any key to continue"
ink RGB(255,255,255),RGB(0,0,0)
wait key
CLS
endif
if namelen>20
cls
set cursor 200,200
ink RGB(255,0,0),RGB(0,0,0)
Print "Please enter shorter name"
set cursor 200,230
Print "Press any key to continue"
ink RGB(255,255,255),RGB(0,0,0)
wait key
CLS
endif
if name$<>"" and namelen<=20 then exit
loop
set text size 25
ink RGB(0,255,0),RGB(0,0,0)
cls
screenW=screen width()
screenH=screen height()
set cursor (screenW/2)-120,(screenH/2)-20
print "Press any key to begin"
wait key
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "3":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "3.":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "3..":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "2":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "2.":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "2..":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "1":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "1.":wait 1000/3
CLS
set cursor (screenW/2)-20,(screenH/2)-20:print "1..":wait 1000/3
CLS
set text size 30
set cursor (screenW/2)-20,(screenH/2)-20:print "GO!":wait 1000/5
sync on
sync rate 60
remstart
load image "Y:\Project\Media\media\level\level2.png",101
load image "Y:\Project\Media\media\level\island1.png",14
load image "Y:\Project\Media\media\dead2.png",150
load image "Y:\Project\Media\media\black.png",151
remend
load image "media\level\level2.png",101
load image "media\level\island1.png",14
load image "media\dead2.png",150
load image "media\black.png",151
sprite 101,0,0,101
sprite 102,0,-2048,101
sprite 23,-150,-150,14
sprite 24,-150,-150,14
sprite 225,-150,-150,14
load image pln$+"1.png",1
load image pln$+"2.png",2
load image pln$+"3.png",3
load image pln$+"player\4.png",4
load image pln$+"player\5.png",5
load image pln$+"player\6.png",6
load image pln$+"player\7.png",7
load image pln$+"player\8.png",8
load image pln$+"player\9.png",9
sprite 1,0,0,1
load image pln$+"life.png",23
sprite 45,-150,-150,23
load image pln$+"life0.png",24
load image pln$+"life1.png",25
load image pln$+"life2.png",26
load image pln$+"life3.png",27
load image pln$+"life4.png",28
load image pln$+"life5.png",29
load image pln$+"life6.png",30
load image pln$+"life7.png",31
load image pln$+"life8.png",32
load image pln$+"life9.png",33
load image msc$+"media\time\time.png",34
load image msc$+"media\time\0.png",35
load image msc$+"media\time\1.png",36
load image msc$+"media\time\2.png",37
load image msc$+"media\time\3.png",38
load image msc$+"media\time\4.png",39
load image msc$+"media\time\5.png",40
load image msc$+"media\time\6.png",41
load image msc$+"media\time\7.png",42
load image msc$+"media\time\8.png",43
load image msc$+"media\time\9.png",44
load image msc$+"media\time\score.png",45
load image msc$+"media\time\blank.png",46
load image msc$+"media\time\ammo.png",47
load image msc$+"media\time\shotsfired.png",48
load image msc$+"media\time\final.png",49
load image msc$+"media\time\health.png",50
load image msc$+"media\time\%.png",60
load image enm$+"blue3.png",51
load image enm$+"blue4.png",52
load image pln$+"japjet2.png",53
sprite 53,0,0,53
sprite 54,0,0,51
sprite 55,0,0,51
sprite 56,0,0,51
scale sprite 54,120
scale sprite 55,120
scale sprite 56,120
load image pln$+"life.png",10
load image wpn$+"dual.png",11
load image wpn$+"dual_rear.png",12
load image msc$+"media\aorb.png",13
load image wpn$+"med_round.png",15
sprite 71,0,0,13
hide sprite 71
load sound snd$+"prop loop.wav",1
set sound volume 1,97
loop sound 1
load sound wpnsnd$+"Machine gun 1.wav",2
set sound volume 2,95
load sound msc$+"sounds\explosions\bomb near.wav",3
set sound volume 3,100
load sound msc$+"sounds\shot impacts\hit car.wav",4
set sound volume 4,100
load sound msc$+"sounds\guns\crossbow.wav",5
set sound volume 5,100
load sound msc$+"sounds\voice\youbedead.wav",6
set sound volume 6,100
load sound wpnsnd$+"Machine gun 1.wav",7
set sound volume 7,88
load sound msc$+"sounds\impacts\hit wall.wav",8
set sound volume 8,100
load sound msc$+"sounds\super weapons\Ripple Lazer.wav",9
set sound volume 9,100
load sound msc$+"sounds\sci-fi fx\space door open.wav",10
set sound volume 10,100
load music msc$+"sounds\OoTShop.mid",1
play music 1
pause music 1
load image xpl$+"b_explode1.png",81
load image xpl$+"b_explode2.png",82
load image xpl$+"b_explode3.png",83
load image xpl$+"b_explode4.png",84
load image xpl$+"b_explode5.png",85
load image xpl$+"b_explode6.png",86
load image xpl$+"b_explode7.png",87
randomize timer()
rem -- Player Config/setup --
playerx=350
playery=500
playerHspeed=6
playerUspeed=3
playerDspeed=6
life=5 `Can go up to 9
playerhealth=100
score=0
ammo=200
firerate=150
shotsfired=0
gametime=0
ammotimer=180
ammotimestart=ammotimer
invincibletime=90
time_so_far=timer()
anim=1
healthtimeget=2000
rem -- Level Config/setup --
lvl1=0
lvl2=-2048
lvlspeed=2.5
mili=60
tophard=6
hardertime=mili*60
island1x=200
island2x=400
island3x=800
island1y=0
island2y=-250
island3y=-750
rem -- Enemy config/setup --
japjet1x=rnd(900)+50
blueplane1x=rnd(900)+50
blueplane2x=rnd(900)+50
blueplane3x=rnd(900)+50
japjet1y=-50
blueplane1y=-50
blueplane2y=-150
blueplane3y=-250
japjethealth=5
japjethealthstart=japjethealth
japjetscore=500
japjetspeed=3
japjetplayerhit=6
japjetfirespeed=5
blueplanehealth=2
blueplane2health=blueplanehealth
blueplay3health=blueplanehealth
blueplanehealthstart=blueplanehealth
blueplanescore=200
blueplanespeed=4
blueplaneplayerhit=3
blueplanefirespeed=7
anim2=51
anim5=51
anim7=51
rem -- Misc Setup/config --
sc1=am1=hl1=0
sc2=am2=hl2=0
sc3=am3=hl3=0
sc4=am4=hl4=0
sc5=am5=hl5=0
sc6=am6=hl6=0
sc7=am7=hl7=0
xplanim=81
zero=0
scorecount=1
size=100
xcord=0
harder=0
hardlimit=0
`--------------------
`-- MAIN GAME LOOP --
`--------------------
do
if keystate(25)=1
gosub pause
endif
inc harder,1
if harder>=hardertime
inc hardlimit,1
harder=0
if hardlimit<=tophard
play sound 10
inc blueplanehealth,2
blueplane2health=blueplanehealth
blueplay3health=blueplanehealth
blueplanehealthstart=blueplanehealth
inc blueplanescore,100
inc blueplanespeed,1
inc blueplaneplayerhit,3
inc blueplanefirespeed,1
inc japjethealth,2
japjethealthstart=japjethealth
inc japjetscore,250
inc japjetspeed,1
inc japjetplayerhit,4
inc japjetfirespeed,1
inc healthtimeget,1000
endif
endif
scorecount=scorecount+1
if scorecount>=60
score=score+1
scorecount=1
inc gametime,1
endif
if gametime>=300
japjetheathstart=10
blueplaneheathstart=5
blueplaneplayerhit=5
japjetplayerhit=10
endif
sprite 27,10,10,45
sprite 26,10,40,47
sprite 25,950,10,life+24
p1ammo$=mid$(str$(ammo),1)
am1=val(p1ammo$)
if ammo<=0
am1=0
endif
p2ammo$=mid$(str$(ammo),2)
am2=val(p2ammo$)
if ammo<10
am2=11
endif
p3ammo$=mid$(str$(ammo),3)
am3=val(p3ammo$)
if ammo<100
am3=11
endif
p4ammo$=mid$(str$(ammo),4)
am4=val(p4ammo$)
if ammo<1000
am4=11
endif
p5ammo$=mid$(str$(ammo),5)
am5=val(p5ammo$)
if ammo<10000
am5=11
endif
sprite 35,65,38,am1+35
sprite 36,80,38,am2+35
sprite 37,95,38,am3+35
sprite 38,110,38,am4+35
sprite 39,125,38,am5+35
rem -- Display score --
p1$=mid$(str$(score),1)
if val(p1$)<>0
sc1=val(p1$)
endif
p2$=mid$(str$(score),2)
if score<10
sc2=11
endif
if score>=10
sc2=val(p2$)
endif
p3$=mid$(str$(score),3)
if score<100
sc3=11
endif
if score>=100
sc3=val(p3$)
endif
p4$=mid$(str$(score),4)
if score<1000
sc4=11
endif
if score>=1000
sc4=val(p4$)
endif
p5$=mid$(str$(score),5)
if score<10000
sc5=11
endif
if score>=10000
sc5=val(p5$)
endif
p6$=mid$(str$(score),6)
if score<100000
sc6=11
endif
if score>=100000
sc6=val(p6$)
endif
p7$=mid$(str$(score),7)
if score<1000000
sc7=11
endif
if score>=1000000
sc7=val(p7$)
endif
sprite 28,65,9,sc1+35
sprite 29,80,9,sc2+35
sprite 30,95,9,sc3+35
sprite 31,110,9,sc4+35
sprite 32,125,9,sc5+35
sprite 33,140,9,sc6+35
sprite 34,155,9,sc7+35
REM -- Display Health % --
p1health$=mid$(str$(playerhealth),1)
if val(p1$)<>0
hl1=val(p1health$)
endif
p2health$=mid$(str$(playerhealth),2)
if playerhealth<10
hl2=25
endif
if playerhealth<1
hl2=11
endif
if playerhealth>=10
hl2=val(p2health$)
endif
p3health$=mid$(str$(playerhealth),3)
if playerhealth<100
hl3=25
endif
if playerhealth<10
hl3=11
endif
if playerhealth>=100
hl3=val(p3health$)
endif
p4health$=mid$(str$(playerhealth),4)
if playerhealth<1000
hl4=25
endif
if playerhealth<100
hl4=11
endif
if playerhealth>=1000
hl4=val(p4health$)
endif
sprite 40,950,40,hl1+35
sprite 41,965,40,hl2+35
sprite 42,980,40,hl3+35
sprite 43,995,40,hl4+35
sprite 44,885,40,50
if playerhealth<=0
dec life,1
playerexplode=1
playerexplodex=playerx
playerexplodey=playery
playerhealth=100
playerx=-1500
play sound 3
endif
if life<=0
goto dead
endif
REM Paralax Scolling
inc lvl1,lvlspeed
if lvl1=>2048 then lvl1=0
inc lvl2,lvlspeed
if lvl2=>0 then lvl2=-2048
inc island1y,lvlspeed
if island1y>=1500
island1y=-150
island1x=rnd(975)+50
island1scale=rnd(50)+50
maybe1=rnd(1)
if maybe1=1
island1scale=island1scale+rnd(100)
endif
scale sprite 23,island1scale
rotate sprite 23,rnd(360)
endif
inc island2y,lvlspeed
if island2y>=1400
island2y=-250
island2x=rnd(975)+50
island2scale=rnd(50)+50
maybe2=rnd(1)
if maybe2=1
island2scale=island2scale+rnd(100)
endif
scale sprite 24,island2scale
rotate sprite 24,rnd(360)
endif
inc island3y,lvlspeed
if island3y>=1400
island3y=-350
island3x=rnd(975)+50
island3scale=rnd(50)+50
maybe3=rnd(1)
if maybe3=1
island3scale=island3scale+rnd(100)
endif
scale sprite 225,island3scale
rotate sprite 225,rnd(360)
endif
sprite 101,0,lvl1,101
sprite 102,0,lvl2,101
if upkey()=1 and playery>20 then dec playery,playerUspeed
if downkey()=1 and playery<720 then inc playery,playerDspeed
if leftkey()=1 and playerx>5
dec playerx,playerHspeed
anim=4
endif
if rightkey()=1 and playerx<965
inc playerx,playerHspeed
anim=7
endif
sprite 1,playerx,playery,anim
enemymove = 53
inc japjet1y,japjetspeed
if sprite hit (enemymove,1) and spawnlife=0
playerexplodey=playery
playerexplodex=playerx
playerx=-1000
playery=-1000
life=life-1
playerhealth=100
playerexplode=1
play sound 3
explode=1
japjet1y=900
endif
if japjet1y>=850
japjet1y=-50
japjet1x=rnd(900)+50
endif
sprite enemymove,japjet1x,japjet1y,53
for fire=2 to 22
if sprite exist(fire)
if sprite hit(fire,53)=1 and sprite visible(fire)=1
japjethealth=japjethealth-1
hide sprite fire
if japjethealth<=0
explodey=japjet1y
explodex=japjet1x
japjet1y=900
explode=1
score=score+japjetscore
japjethealth=japjethealthstart
play sound 3
endif
endif
endif
next fire
inc enemymove,1
inc blueplane1y,blueplanespeed
if sprite hit (enemymove,1) and spawnlife=0
playerexplodey=playery
playerexplodex=playerx
playerx=-1000
playery=-1000
life=life-1
playerhealth=100
playerexplode=1
play sound 3
explode=1
blueplane1y=900
endif
if blueplane1y>=850
blueplane1y=-50
blueplane1x=rnd(900)+50
endif
inc anim3
if anim3>=2
inc anim2,1
if anim2>=53 then anim2=51
anim3=0
endif
sprite enemymove,blueplane1x,blueplane1y,anim2
for fire=2 to 22
if sprite exist(fire)
if sprite hit(fire,54)=1 and sprite visible(fire)=1
blueplanehealth=blueplanehealth-1
hide sprite fire
if blueplanehealth<=0
explodey=blueplane1y
explodex=blueplane1x
blueplane1y=900
explode=1
score=score+blueplanescore
blueplanehealth=blueplanehealthstart
play sound 3
endif
endif
endif
next fire
inc enemymove,1
inc blueplane2y,blueplanespeed
if sprite hit (enemymove,1) and spawnlife=0
playerexplodey=playery
playerexplodex=playerx
playerx=-1000
playery=-1000
life=life-1
playerhealth=100
playerexplode=1
play sound 3
explode=1
blueplane2y=900
endif
if blueplane2y>=850
blueplane2y=-50
blueplane2x=rnd(900)+50
endif
inc anim4
if anim4>=2
inc anim5,1
if anim5>=53 then anim5=51
anim4=0
endif
sprite enemymove,blueplane2x,blueplane2y,anim5
for fire=2 to 22
if sprite exist(fire)
if sprite hit(fire,55)=1 and sprite visible(fire)=1
blueplane2health=blueplane2health-1
hide sprite fire
if blueplane2health<=0
explodey=blueplane2y
explodex=blueplane2x
blueplane2y=900
explode=1
score=score+blueplanescore
blueplane2health=blueplanehealthstart
play sound 3
endif
endif
endif
next fire
inc enemymove,1
inc blueplane3y,blueplanespeed
if sprite hit (enemymove,1) and spawnlife=0
playerexplodey=playery
playerexplodex=playerx
playerx=-1000
playery=-1000
life=life-1
playerhealth=100
playerexplode=1
play sound 3
explode=1
blueplane3y=900
endif
if blueplane3y>=850
blueplane3y=-50
blueplane3x=rnd(900)+50
endif
inc anim6
if anim6>=2
inc anim7,1
if anim7>=53 then anim7=51
anim6=0
endif
sprite enemymove,blueplane3x,blueplane3y,anim7
for fire=2 to 22
if sprite exist(fire)
if sprite hit(fire,56)=1 and sprite visible(fire)=1
blueplane3health=blueplane3health-1
hide sprite fire
if blueplane3health<=0
explodey=blueplane3y
explodex=blueplane3x
blueplane3y=900
explode=1
score=score+blueplanescore
blueplane3health=blueplanehealthstart
play sound 3
endif
endif
endif
next fire
if ammo<=0 and sprite visible(71)=0
inc deadammo,1
if deadammo=>300
show sprite 71
sprite 71,rnd(900)+50,rnd(600)+50,13
deadammo=0
amgettime=180
endif
endif
inc ammotime,1
if ammotime>=2000
amget=rnd(10)
if amget>=5
show sprite 71
sprite 71,rnd(900)+50,rnd(600)+50,13
amgettime=200
endif
amget=0
ammotime=0
endif
if amgettime>0
dec amgettime,1
endif
if amgettime<=0 and sprite visible(71)=1
hide sprite 71
endif
if sprite hit(71,1) and sprite visible(71)=1
inc ammo,100
hide sprite 71
amgettime=0
play sound 5
endif
inc healthtime,1
if healthtime>=healthtimeget and life<9
hlget=rnd(10)
if hlget>=5
show sprite 45
sprite 45,rnd(900)+50,rnd(600)+50,23
hlgettime=200
endif
hlget=0
healthtime=0
endif
if hlgettime>0
dec hlgettime,1
endif
if hlgettime<=0 and sprite visible(45)=1
hide sprite 45
endif
if sprite hit(45,1) and sprite visible(45)=1
play sound 9
inc life,1
hide sprite 45
hlgettime=0
endif
if explode=1
inc explode2,1
if explode2>=10
sprite 80,explodex,explodey,xplanim
offset sprite 80,-16,0
xplanim=xplanim+1
if xplanim>=88
explode=0
xplanim=81
delete sprite 80
explode2=1
endif
endif
endif
if playerexplode=1
inc explode3,1
if explode3>=10
sprite 80,playerexplodex,playerexplodey,xplanim
offset sprite 80,-16,0
xplanim=xplanim+1
if xplanim>=88
playerexplode=0
xplanim=81
delete sprite 80
explode3=1
endif
endif
endif
if playerx<=-100
playerdead=1
endif
if playerdead=1
set sprite alpha 1,120
inc spawntime,1
if spawntime>=60
playerx=350
playery=500
spawntime=0
spawnlife=1
endif
playerdead=0
endif
if spawnlife=1
inc spawnlifetime,1
if spawnlifetime>=invincibletime
spawnlife=0
spawnlifetime=0
set sprite alpha 1,255
endif
endif
anim=anim+1
if anim=>4 then anim=1
rem -- Player Fire --
if controlkey()=1 and ammo>0
if timer() > time + firerate
ammo=ammo-1
gosub bullet_position
shotsfired=shotsfired+1
play sound 2
endif
endif
for z = 2 to 22
inc sy(z),-5
sprite z,sx(z)+19,sy(z),11
scale sprite z,110
if sy(z) < -10 then delete sprite z
next z
rem -- Enemy fire --
if playerx>=japjet1x-75 and playerx<=japjet1x+75 and playery>japjet1y+50
if timer() > enemytime + 300
gosub japjet1_bullet
play sound 7
endif
endif
for enemyfire = 2 to 22
inc jj1y(enemyfire),japjetfirespeed
sprite enemyfire+300,jj1x(enemyfire)+35,jj1y(enemyfire)+50,12
scale sprite enemyfire+300, 75
if sprite hit(enemyfire+300,1) and sprite visible(enemyfire+300)=1 and spawnlife=0
hide sprite enemyfire+300
play sound 8
dec playerhealth,japjetplayerhit
endif
if jj1y(enemyfire) > 1200 then delete sprite enemyfire+300
next enemyfire
if playerx>=blueplane1x-75 and playerx<=blueplane1x+75 and playery>blueplane1y+50
if timer() > enemytime2 + 200
gosub blueplane1_bullet
play sound 7
endif
endif
for enemyfire = 2 to 22
inc bp1y(enemyfire),blueplanefirespeed
sprite enemyfire+325,bp1x(enemyfire)+16,bp1y(enemyfire)+40,15
if sprite hit(enemyfire+325,1) and sprite visible(enemyfire+325)=1 and spawnlife=0
hide sprite enemyfire+325
play sound 8
dec playerhealth,blueplaneplayerhit
endif
if bp1y(enemyfire) > 1200 then delete sprite enemyfire+325
next enemyfire
if playerx>=blueplane2x-75 and playerx<=blueplane2x+75 and playery>blueplane2y+50
if timer() > enemytime3 + 200
gosub blueplane2_bullet
play sound 7
endif
endif
for enemyfire = 2 to 22
inc bp2y(enemyfire),blueplanefirespeed
sprite enemyfire+350,bp2x(enemyfire)+16,bp2y(enemyfire)+40,15
if sprite hit(enemyfire+350,1) and sprite visible(enemyfire+350)=1 and spawnlife=0
hide sprite enemyfire+350
play sound 8
dec playerhealth,2
endif
if bp2y(enemyfire) > 1200 then delete sprite enemyfire+350
next enemyfire
if playerx>=blueplane3x-75 and playerx<=blueplane3x+75 and playery>blueplane3y+50
if timer() > enemytime4 + 200
gosub blueplane3_bullet
play sound 7
endif
endif
for enemyfire = 2 to 22
inc bp3y(enemyfire),blueplanefirespeed
sprite enemyfire+375,bp3x(enemyfire)+16,bp3y(enemyfire)+40,15
if sprite hit(enemyfire+375,1) and sprite visible(enemyfire+375)=1 and spawnlife=0
hide sprite enemyfire+375
play sound 8
dec playerhealth,2
endif
if bp3y(enemyfire) > 1200 then delete sprite enemyfire+375
next enemyfire
rem -- draws the islands last to ensure they are always below game sprites --
sprite 23,island1x,island1y,14
sprite 24,island2x,island2y,14
sprite 225,island3x,island3y,14
Enemymove=53
sync
loop
REM ----------------------
REM -- END OF GAME LOOP --
REM ----------------------
bullet_position:
inc a,1
if a = 22 then a = 2
sx(a) = sprite x(1)
sy(a) = sprite y(1)
time = timer()
return
japjet1_bullet:
inc b,1
if b = 22 then b = 2
jj1x(b) = sprite x(53)
jj1y(b) = sprite y(53)
enemytime = timer()
return
blueplane1_bullet:
inc c,1
if c = 22 then c = 2
bp1x(c) = sprite x(54)
bp1y(c) = sprite y(54)
enemytime2 = timer()
return
blueplane2_bullet:
inc d,1
if d = 22 then d = 2
bp2x(d) = sprite x(55)
bp2y(d) = sprite y(55)
enemytime3 = timer()
return
blueplane3_bullet:
inc e,1
if e = 22 then e = 2
bp3x(e) = sprite x(56)
bp3y(e) = sprite y(56)
enemytime4 = timer()
return
pause:
stop sound 1
resume music 1
hide all sprites
text 400,400, "GAME PAUSED"
sync
wait key
show all sprites
pause music 1
loop sound 1
return
REM ---------------------
REM -- Go here if dead --
REM ---------------------
dead:
delete image 35:load image msc$+"media\time\0-2.png",35
delete image 36:load image msc$+"media\time\1-2.png",36
delete image 37:load image msc$+"media\time\2-2.png",37
delete image 38:load image msc$+"media\time\3-2.png",38
delete image 39:load image msc$+"media\time\4-2.png",39
delete image 40:load image msc$+"media\time\5-2.png",40
delete image 41:load image msc$+"media\time\6-2.png",41
delete image 42:load image msc$+"media\time\7-2.png",42
delete image 43:load image msc$+"media\time\8-2.png",43
delete image 44:load image msc$+"media\time\9-2.png",44
stop sound 1
sprite 150,0,0,150
play sound 6
sync
wait 3000
sprite 151,0,0,151
do
rem -- Prints score using sprites --
p1$=mid$(str$(score),1)
if val(p1$)<>0
sc1=val(p1$)
endif
p2$=mid$(str$(score),2)
if score<10
sc2=11
endif
if score>=10
sc2=val(p2$)
endif
p3$=mid$(str$(score),3)
if score<100
sc3=11
endif
if score>=100
sc3=val(p3$)
endif
p4$=mid$(str$(score),4)
if score<1000
sc4=11
endif
if score>=1000
sc4=val(p4$)
endif
p5$=mid$(str$(score),5)
if score<10000
sc5=11
endif
if score>=10000
sc5=val(p5$)
endif
p6$=mid$(str$(score),6)
if score<100000
sc6=11
endif
if score>=100000
sc6=val(p6$)
endif
p7$=mid$(str$(score),7)
if score<1000000
sc7=11
endif
if score>=1000000
sc7=val(p7$)
endif
sprite 153,260,150,sc1+35:scale sprite 153,200
sprite 154,290,150,sc2+35:scale sprite 154,200
sprite 155,320,150,sc3+35:scale sprite 155,200
sprite 156,350,150,sc4+35:scale sprite 156,200
sprite 157,380,150,sc5+35:scale sprite 157,200
sprite 158,410,150,sc6+35:scale sprite 158,200
sprite 159,440,150,sc7+35:scale sprite 159,200
sprite 160,150,150,45:scale sprite 160,200
rem -- prints shots fired using sprites --
p1shots$=mid$(str$(shotsfired),1)
sh1=val(p1shots$)
if shotsfired<=0
sh1=0
endif
p2shots$=mid$(str$(shotsfired),2)
sh2=val(p2shots$)
if shotsfired<10
sh2=11
endif
p3shots$=mid$(str$(shotsfired),3)
sh3=val(p3shots$)
if shotsfired<100
sh3=11
endif
p4shots$=mid$(str$(shotsfired),4)
sh4=val(p4shots$)
if shotsfired<1000
sh4=11
endif
p5shots$=mid$(str$(shotsfired),5)
sh5=val(p5shots$)
if shotsfired<10000
sh5=11
endif
p6shots$=mid$(str$(shotsfired),6)
sh6=val(p6shots$)
if shotsfired<100000
sh6=11
endif
p7shots$=mid$(str$(shotsfired),7)
sh7=val(p7shots$)
if shotsfired<1000000
sh7=11
endif
sprite 161,148,200,48:scale sprite 161,200
sprite 164,360,200,sh1+35:scale sprite 164,200
sprite 163,145,275,49:scale sprite 163,200
sprite 165,390,200,sh2+35:scale sprite 165,200
sprite 166,420,200,sh3+35:scale sprite 166,200
sprite 167,450,200,sh4+35:scale sprite 167,200
sprite 168,480,200,sh5+35:scale sprite 168,200
sprite 169,510,200,sh6+35:scale sprite 169,200
sprite 170,540,200,sh7+35:scale sprite 170,200
finalscore=score+ammo-(shotsfired/4)+gametime
p1final$=mid$(str$(finalscore),1)
f1=val(p1final$)
if finalscore<=0
f1=0
endif
p2final$=mid$(str$(finalscore),2)
f2=val(p2final$)
if finalscore<10
f2=11
endif
p3final$=mid$(str$(finalscore),3)
f3=val(p3final$)
if finalscore<100
f3=11
endif
p4final$=mid$(str$(finalscore),4)
f4=val(p4final$)
if finalscore<1000
f4=11
endif
p5final$=mid$(str$(finalscore),5)
f5=val(p5final$)
if finalscore<10000
f5=11
endif
p6final$=mid$(str$(finalscore),6)
f6=val(p6final$)
if finalscore<100000
f6=11
endif
p7final$=mid$(str$(finalscore),7)
f7=val(p7final$)
if finalscore<1000000
f7=11
endif
sprite 171,360,275,f1+35:scale sprite 171,200
sprite 172,390,275,f2+35:scale sprite 172,200
sprite 173,420,275,f3+35:scale sprite 173,200
sprite 174,450,275,f4+35:scale sprite 174,200
sprite 175,480,275,f5+35:scale sprite 175,200
sprite 176,510,275,f6+35:scale sprite 176,200
sprite 177,540,275,f7+35:scale sprite 177,200
if load=0
load array scorearray$,score$()
load=1
bottomscore$=score$(10,1)
if finalscore>val(bottomscore$)
score$(10,0)=name$
score$(10,1)=str$(finalscore)
endif
do
swap=0
for x=1 to 10
scorestr1$=score$(x,1)
scorestr2$=score$(x+1,1)
scoreval1=val(scorestr1$)
scoreval2=val(scorestr2$)
if scoreval2>scoreval1
name1$=score$(x,0)
name2$=score$(x+1,0)
score$(x,0)=name2$
score$(x+1,0)=name1$
score$(x,1)=str$(scoreval2)
score$(x+1,1)=str$(scoreval1)
swap=1
endif
next x
if swap=0 then exit
loop
endif
hide all sprites
set text size 20
set text to bold
load bitmap "media\time\cabesoft2.jpg",0
CLS
for z=152 to 177
if sprite exist (z)=1
show sprite z
endif
next z
for y=1 to 10
if score$(y,1)=str$(finalscore)
highlightfinal=y
endif
next y
value = 150
for x=1 to 10
if x<4
ink rgb(0,255,0),RGB(0,0,0)
endif
if x>=4
ink rgb(255,255,255),RGB(0,0,0)
endif
if x=highlightfinal
ink rgb(255,0,0),rgb(0,0,0)
endif
if x<10
set cursor 600,value
print str$(x)+" -- "+score$(x,0)+" -- "+score$(x,1)
value=value+30
endif
if x=10
set cursor 590,value
print str$(x)+" -- "+score$(x,0)+" -- "+score$(x,1)
value=value+30
endif
next x
save array scorearray$,score$()
sync
loop
wait key
Comments etc are appretiated