sync on:sync rate 120
 
randomize timer()
 
draw sprites first
draw to front
 
 
global dim level(10100)
global dim enemies(10000,2)
global dim blocks(10000,2)
global dim tanks(10000,2)
 
 
global lives
global death
global score
global invinsable
global totalblock
global gas
global totaltank
global screeny#
global speed#
global basespeed
 
 
set image colorkey 255,0,255
 
ink rgb(0,100,0),rgb(0,100,0)
box 0,0,100,600
get image 10,0,0,100,600
cls
 
 
 
restore plane
image(1,4)
 
restore bullet
image(2,4)
 
restore heli
image(3,5)
 
restore block
image(4,15)
 
restore outline
image(5,2)
 
ink rgb(100,0,0),rgb(100,0,0)
 
box 0,0,100,12
get image 6,0,0,100,12
cls
 
box 0,0,50,50
get image 7,0,0,50,50
cls
 
 
do
 
   undim level()
   undim enemies()
   undim blocks()
   undim tanks()
   global dim level(10100)
   global dim enemies(10000,2)
   global dim blocks(10000,2)
   global dim tanks(10000,2)
 
   death=0
   score=0
   invinsable=255
   screeny#=0
   speed#=0
   basespeed=1
   totalblock=0
   totaltank=0
   gas=2000
   x=0
   y=0
 
   lives=3
 
   for i=1 to 10000
      a=rnd(30)
 
      if x=10
 
         if y mod 4=0
            level(i-rnd(9)-1)=4
         endif
 
         y=y+1
         x=0
         fue=0
 
         if rnd(10)=1 and y>6
            for j=0 to 2
               for k=0 to j
                  level(i-47+j*10-k)=3
                  level(i-46+j*10+k)=3
               next k
            next j
 
            for j=0 to 1
               for k=0 to j
                  level(i-7-j*10-k)=3
                  level(i-6-j*10+k)=3
               next k
            next j
 
         endif
 
      endif
 
      x=x+1
 
      select a
         case 1
            level(i)=1
            w=1
         endcase
 
      endselect
 
      if w=0 then level(i)=0
      w=0
 
   next i
 
   level(i+1)=-999
 
 
 
 
 
   sprite 1,400,450,1
   set sprite priority 1,1
 
 
 
   sprite 1000,0,0,10
   sprite 1001,700,0,10
 
   make_level()
 
   repeat
 
      flash=flash+1
 
      ink rgb(255,255,255),rgb(255,255,255)
 
      if flash<100
         center text screen width()/2,screen height()/2-100,"Press Space to Start"
      endif
 
      if flash>200 then flash=0
 
      sync
 
   until spacekey()=1
 
   repeat
      sync
   until screen fps()>0
 
   repeat
      if invinsable>0
         set sprite alpha 1,255-invinsable
         invinsable=invinsable-1
      endif
 
 
      text 0,0,str$(screen fps())
 
 
      a=a-1
      a=fire(a)
 
      move_tank()
 
 
 
 
 
      control_enemy()
      screeny#=screeny#-speed#
 
      move_blocks()
 
      fuel()
      display()
      move()
 
 
      sync
 
   until death=2
 
 
 
   for i=10 to enemies(0,0)+9
      if sprite exist(i)=1 then delete sprite i
   next i
   for i=1002 to totalblock+1001
      if sprite exist(i)=1 then delete sprite i
   next i
   for i=500 to totaltank+499
      if sprite exist(i)=1 then delete sprite i
    next i
 
loop
 
function fuel()
 
   if gas=0
      die()
   endif
 
   col=sprite collision(1,0)
 
   if col>500 and col<1000
      gas=2000
   endif
 
   center text screen width()/2,500,"Fuel"
 
   sprite 7,screen width()/2-51,550,5
   sprite 8,screen width()/2-49,550+2,6
   set sprite priority 7,1
   set sprite priority 8,1
 
   stretch sprite 8,gas/20,100
 
   gas=gas-1
 
endfunction
 
function display()
 
   ink rgb(255,255,255),rgb(255,255,255)
 
   text 150,10,"Lives: "+str$(lives)
   text 500,10,"Score: "+str$(score)
 
endfunction
 
function move()
 
   f#=screen fps()
 
   if upkey()=1
      if f#>0
         f#=120/f#
         speed#=(basespeed+1)*(f#)
      else
         speed#=(basespeed+1)
      endif
   else
      if f#>0
         f#=120/f#
         speed#=(basespeed)*(f#)
      else
         speed#=(basespeed)
      endif
   endif
 
   f#=screen fps()
 
   if rightkey()=1
      rotate sprite 1,90
      move sprite 1,ceil(240/f#)
      rotate sprite 1,0
   endif
 
   if leftkey()=1
      rotate sprite 1,-90
      move sprite 1,ceil(240/f#)
      rotate sprite 1,0
   endif
 
   col=sprite collision(1,0)
 
   if col>=1000 and invinsable=0
      die()
   endif
 
   basespeed=int(screeny#/-10000)+1
   if basespeed>3 then basespeed=3
 
 
 
endfunction
 
function fire(a)
 
   if spacekey()=1 and a=<0
      for i=2 to 6
         if sprite exist(i)=0 then spr=i
         a=screen fps()/2
      next i
      if spr>0 then sprite spr,sprite x(1)+sprite width(1)/2-2,450,2
   endif
 
   for i=2 to 6
      if sprite exist(i)
         f#=screen fps()
         f#=240/f#
         move sprite i,ceil(f#)
         if sprite y(i)<0 then delete sprite i
      endif
   next i
 
 
endfunction a
 
 
function control_enemy()
 
   f#=screen fps()
 
   for i=10 to enemies(0,0)+9
 
 
      if sprite exist(i)
         move sprite i,-speed#
 
 
 
         if sprite y(i)>300 and sprite y(i)<500
            rotate sprite i,90
            if sprite exist(1)
              if sprite x(1)>sprite x(i)
                 move sprite i,ceil(120/f#)
 
                 if sprite collision(i,0)>1000
                    move sprite i,-ceil(120/f#)
                 endif
              else
                 move sprite i,-ceil(120/f#)
                 if sprite collision(i,0)>1000
                    move sprite i,ceil(120/f#)
                 endif
              endif
            endif
            rotate sprite i,0
         endif
 
         col=sprite collision(i,0)
 
         if col=1 and invinsable=0
            delete sprite i
            enemies(i-9,1)=-5
            die()
         endif
 
 
         for j=2 to 6
            if sprite exist(j)=1 and sprite exist(i)=1
               if sprite collision(i,j)=1
                  delete sprite i
                  delete sprite j
                  enemies(i-9,1)=-5
                  score=score+100
               endif
            endif
         next j
 
         if enemies(i-9,2)>screeny#+600 and sprite exist(i)=1
            delete sprite i
            enemies(i-9,1)=-5
         endif
 
      else
         if enemies(i-9,1)>0 and enemies(i-9,2)>screeny# and enemies(i-9,2)<screeny#+600
            sprite i,enemies(i-9,1),enemies(i-9,2)-screeny#,3
         endif
      endif
 
   next i
 
endfunction
 
function die()
 
   gas=2000
   lives=lives-1
   invinsable=255
   sprite 1,400,450,1
 
   if lives=0
      selection=1
      repeat
         set text size 20
         center text screen width()/2,screen height()/2,"GAME OVER"
         set text size 10
         center text screen width()/2,screen height()/2+50,"Score: "+str$(score)
         center text screen width()/2,screen height()/2+75,"Play again?"
 
         if rightkey()=1 then selection=2
         if leftkey()=1 then selection=1
 
         if selection=1
            ink rgb(100,100,0),rgb(100,100,0)
            center text screen width()/2-50,screen height()/2+100,"Yes"
            ink rgb(255,255,255),rgb(255,255,255)
            center text screen width()/2+50,screen height()/2+100,"No"
         endif
 
         if selection=2
            ink rgb(255,255,255),rgb(255,255,255)
            center text screen width()/2-50,screen height()/2+100,"Yes"
            ink rgb(100,100,0),rgb(100,100,0)
            center text screen width()/2+50,screen height()/2+100,"No"
         endif
 
         sync
 
         ink rgb(255,255,255),rgb(255,255,255)
 
      until returnkey()=1
 
 
 
      if selection=2
         end
      else
         death=2
      endif
 
 
   endif
 
endfunction
 
function make_enemy(x,y)
 
   enemies(0,0)=enemies(0,0)+1
   enemies(enemies(0,0),1)=x
   enemies(enemies(0,0),2)=y
 
endfunction
 
function make_level()
 
 
   x=100
 
   repeat
 
      i=i+1
      a=level(i)
 
      x=x+60
      if x=>700
         x=100
         y=y-60
      endif
 
      if a=1
         make_enemy(x,y)
      endif
 
      if a=3
         make_block(x,y)
      endif
 
      if a=4
         make_fuel_tank(x,y)
      endif
 
 
   until a=-999
 
endfunction
 
function make_block(x,y)
 
   totalblock=totalblock+1
   blocks(totalblock,1)=x
   blocks(totalblock,2)=y
 
endfunction
 
function move_blocks()
   for i=1002 to 1002+totalblock-1
      if sprite exist(i)
         move sprite i,-speed#
         if blocks(i-1001,2)>screeny#+600
            delete sprite i
            blocks(i-1001,1)=-5
         endif
      else
         if blocks(i-1001,1)>0 and blocks(i-1001,2)>screeny# and blocks(i-1001,2)<screeny#+600
            sprite i,blocks(i-1001,1),blocks(i-1001,2)-screeny#,4
         endif
      endif
 
   next i
endfunction
 
function make_fuel_tank(x,y)
 
   totaltank=totaltank+1
   tanks(totaltank,1)=x
   tanks(totaltank,2)=y
 
endfunction
 
function move_tank()
   for i=500 to 500+totaltank-1
      if sprite exist(i)
         move sprite i,-speed#
         if tanks(i-499,2)>screeny#+600
            delete sprite i
            tanks(i-499,1)=-5
         endif
      else
         if tanks(i-499,1)>0 and tanks(i-499,2)>screeny# and tanks(i-499,2)<screeny#+600
            sprite i,tanks(i-499,1),tanks(i-499,2)-screeny#,7
         endif
      endif
   next i
endfunction
 
function image(num,size)
 
   dim colors(100,3)
 
   read a$
   a$=a$+"-"
 
   repeat
      i=i+1
 
      for j=1 to len(a$)
 
         c$=c$+b$
         b$=mid$(a$,j)
 
         if b$="-" or b$=" "
            k=k+1
            colors(i,k)=val(c$)
            c$=""
            b$=""
         endif
 
      next j
 
      k=0
      read a$
      a$=a$+"-"
 
   until a$="XXX-"
 
 
   x=0
   y=0
 
   repeat
      read a
      x=x+1
 
      if a>0 and a<100
         ink rgb(colors(a,1),colors(a,2),colors(a,3)),rgb(colors(a,1),colors(a,2),colors(a,3))
         box (x-1)*size,(y-1)*size,x*size,y*size
      endif
 
      if a=0
         ink rgb(255,0,255),rgb(255,0,255)
         box (x-1)*size,(y-1)*size,x*size,y*size
      endif
 
      if a=100
         y=y+1
         x=0
      endif
 
   until a=-999
 
   get image num,0,0,(x-1)*size,y*size
 
   cls
 
endfunction
 
plane:
data "255-255-0"
data "XXX"
 
data 0,0,0,0,1,0,0,0,0,100
data 0,0,0,0,1,0,0,0,0,100
data 0,0,0,1,1,1,0,0,0,100
data 0,0,1,1,1,1,1,0,0,100
data 0,1,1,0,1,0,1,1,0,100
data 1,1,0,0,1,0,0,1,1,100
data 0,0,0,0,1,0,0,0,0,100
data 0,0,0,1,1,1,0,0,0,100
data 0,0,1,1,0,1,1,0,0,-999
 
bullet:
data "255-255-0"
data "XXX"
 
data 1,100
data 1,100
data 1,100
data 1,100
data 1,100
data 1,100
data 1,100
data 1,100
data 1,-999
 
heli:
data "238 154 0","34-139-34"
data "XXX"
 
data 0,0,0,0,0,0,0,0,0,100
data 0,0,0,0,0,1,1,0,0,100
data 0,0,0,0,0,0,0,1,1,100
data 2,0,0,0,0,2,2,2,0,100
data 2,2,2,2,2,2,2,2,2,100
data 2,0,0,0,0,2,2,2,2,100
data 0,0,0,0,0,0,2,2,0,100
data 0,0,0,0,0,1,1,1,1,-999
 
block:
data "0 100 0"
data "XXX"
 
data 1,1,1,1,100
data 1,1,1,1,100
data 1,1,1,1,100
data 1,1,1,1,100
data 1,1,1,1,-999
 
outline:
data "0 0 0"
data "XXX"
 
data 100
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,100
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,100
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,100
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,100
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,100
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,100
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,100
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-999