'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
'       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'       @@ -=Let's Start Again From Scratch!=- @@
'       @@            -=Jet-Pac=-              @@
'       @@-=Coded by: Mr. Shockwave (C) 2001.=-@@
'       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'
'
' The original version of this had scrolling levels but I
'  wasn't happy with it as there wasn't enough going on 
' I wanted to make an anarchic blast 'em up with loads of
' enemys, bullets and missiles on the screen at once and
'  see if I could keep it all tight and in 50 frames/sec
'       I think I've managed it! Enjoy the game...
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

'####################################################
'## Initial Setup! Definition of control variables ##
'## and arrays mainly.=-                           ##
'####################################################
open window 640,512

 high=10000 : rem High Score default
 plbul=8 :    rem Max player bullets on screen
 grnden=7 :   rem Maximum number of ground enemies
 airmines=5 : rem amount of airborne mines to have
 nstr=20 :    rem Amount of background stars to have
 dim mountains(10) : rem   Background scenery
  dim levels(5,70) : Rem   Holds All the levels!
dim curlevel(5,14) : Rem Just holds the current level!
  dim pbs(plbul): rem Status array for player bullet
  dim pbx(plbul): rem Player bullet x position
  dim pby(plbul): rem Player bullet Y position
dim gnx(grnden) : rem Ground enemys X pos
dim gny(grnden) : rem Ground enemys y pos
dim gnd(grnden) : rem direction of movement 1 or -1
dim gns(grnden) : rem Status 0=ok 1-49 exploding 50=dead
dim gmx(grnden) : rem Guided missile x co-ordinate
dim gmy(grnden) : rem Guided missile x co-ordinate
dim gmxo(grnden) : rem Guided missile x co-ordinate
dim gmyo(grnden) : rem Guided missile x co-ordinate

dim gms(grnden) : rem Guided missile status
dim amx(airmines) : rem Air mine x-co-ordinate
dim amy(airmines) : rem Air mine Y-co-ordinate
dim ams(airmines) : rem Status array for mines
dim stx(nstr) : rem X co-ord for background stars effect
dim sty(nstr) : rem Y co-ord  "      "        "     "
dim sts(nstr) : rem Used for star speed and size

'###########################################
'## Scrolling message for title screen!=- ##
'###########################################

s$="                                               "
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
s$=s$+"IN THIS GAME YOU MUST DESTROY PLATFORM TANKS WITH "
s$=s$+"THE AID OF YOUR TRUSTY PULSE RIFLE.. YOU ALSO HAVE"
s$=s$+" AN EXPERIMENTAL JETPAC THAT ALLOWS YOU TO BOOST "
s$=s$+"YOUR WAY AROUND THE LEVELS.. AS YOU ARE TRYING TO "
s$=s$+"KILL THE TANKS THEY WILL FIRE HEAT SEAKERS AT YOU "
s$=s$+"AND THIER MOTHERSHIP WILL DROP GUIDED PROXIMITY "
s$=s$+"MINES THAT WILL SEEK YOU AND EXPLODE ON CONTACT! "
s$=s$+"  IF YOU COLLIDE WITH A TANK IT WILL TAKE YOUR"
s$=s$+" ENERGY AND REPAIR ANY DAMAGE YOU'VE DONE TO IT! "
s$=s$+" BEWARE OF FALLING TOO FAR AS WELL.. USE THE "
s$=s$+"JETPAC TO SLOW DOWN YOUR DESCENT. DON'T FALL INTO "
s$=s$+"THE WATER EITHER AS IT IS ACID AND IT WILL SAP "
s$=s$+"YOUR ENERGY.  IF YOU RUN OUT OF FUEL OR AMMO THEN "
s$=s$+"YOU NEED TO RECHARGE ON A RED PLATFORM...  ALSO "
s$=s$+"IT IS POSSIBLE TO GET BACK YOUR ENERGY LIKE THIS "
s$=s$+"TOO....  IF YOUR ENERGY RUNS OUT.. GAME UNDER!!  "
s$=s$+"TRY AND BEAT THE HIGH SCORE!!   HOPE YOU ENJOY THE"
s$=s$+" GAME.. SPECIAL GREETINGS TO THESE SPECIAL PEOPLE:"
s$=s$+"     ADAM LAY.. I CAN'T THANK YOU ENOUGH FOR THE "
s$=s$+"WEBSITE!!    XALTHORN.. THANKS FOR THE GREAT CODE "
s$=s$+"AND THE FEEDBACK ON MY STUFF. YOUR PACMAN IS VERY "
s$=s$+"NICE INDEED!!    DOCTOR..  THANK'S FOR YOUR EMAILS"
s$=s$+" AND POSTINGS ON THE FORUMS!  GOOD GAMES TOO!!   "
s$=s$+" FRYER.. NICE PROGRAMS M8!    MASTER TONBERRY.. "
s$=s$+" WHEN YOU GETTING YOUR XPORT?     PSI-2 MAG.. "
s$=s$+" DON'T DITCH THE YABASIC SAVES!    JACOB BUSBY.. "
s$=s$+" THANKS FOR THE POSITIVE POSTINGS..   AND THESE: "
s$=s$+" JINX, MONKEYPANTS, AND ALL THE OTHER FORUM USERS "
s$=s$+" (SORRY IF I FORGOT YOU!) AND LAST BUT NOT LEAST, "
s$=s$+"VICKI (MY LONG SUFFERING GIRLFRIEND) AND ALSO "
s$=s$+"ALL MY PERSONAL FRIENDS..   CONTACT ME AT THE "
s$=s$+"FORUMS ON WWW.YABASIC.CO.UK..   THAT'S ALL 4 NOW!"
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scx=110 : rem Left X boundary for scrolltext
    p=0 : rem Text pointer 
'########################################
'## Create Star Positions and speeds=- ##
'########################################
for a=1 to nstr
  stx(a)=ran(640)
  sty(a)=ran(400)
  sts(a)=int(ran(5))+1
next a
'###############################################
'## Create heights for background landscape=- ##
'###############################################
for a=1 to 10
  mountains(a)=100+ran(300)
next a
'#################################################
'## Read all the levels into the master array=- ##
'#################################################
for y=1 to 70
for x=1 to 5
  read levels(x,y)
next x
next y
'##################################
'## The Game Cycle Starts Below: ##
'##################################
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
label start
'##########################
'## Call Title Screen!=- ##
'##########################
 gosub titlescreen
        score=0 : rem Reset score 
 difficult=1500 : rem Reset difficulty level
        level=0 : rem Reset level
         dead=0 : rem Reset death flag
'#########################################
'## The Games Outer Loop Starts Below=- ##
'#########################################
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
repeat
'#######################################################
'## Set difficulty, choose level, set level pointer=- ##
'#######################################################
difficult=difficult-100
if difficult<100 difficult=100
level=level+1
if level>5 level=1
l=14*(level-1)
'########################
'## Introduce Level!=- ##
'########################
a=0
for b=1 to 100 
if b<50 a=a+5
if b>50 a=a-5
   setdrawbuf dw
   dw=1-dw
   setdispbuf dw
setrgb 1,a/1,a/4,a/4
setrgb 2,a/2,a/3,a/3
setrgb 3,a/3,a/2,a/2

   gtriangle 0,0 to 640,512 to 0,512
   gtriangle 0,0 to 640,512 to 640,0

setrgb 1,a*2,a*3,a*4
    text 265-5+ran(10),200-2+ran(4),"J-E-T P-A-C"
    text 265-5+ran(10),220-2+ran(4),"==========="
    text 265-5+ran(10),250-2+ran(4),"LEVEL : "+str$(level)
    text 265-5+ran(10),290-2+ran(4),"GET - READY"
    text 265-5+ran(10),310-2+ran(4),"==========="
next b

'#########################
'## Initialise Level!=- ##
'#########################
gosub drawscorepanel
face=2
score2=score
red=0 : rem These are used for lighting effects:
grn=0
blu=0

energy=100 : Rem Re-charge energy etc!
  ammo=100
  fuel=100
  grav=0
  thrust=0

'############################
'## Get level structure:=- ##
'############################
y2=0
grnden=1
for y=l to l+14
for x=1 to 5
  curlevel(x,y2)=levels(x,y)
  if curlevel(x,y2)=5 then
    plx=(128*x)-64
    ply=(32*y2)
    curlevel(x,y2)=0
  end if
  if curlevel(x,y2)=6 then
    gnx(grnden)=(128*x)-64
    gny(grnden)=(32*y2)
    gnd(grnden)=1
    gns(grnden)=0
    gms(grnden)=0
    if ran(100)<50 gnd(grnden)=-1
    curlevel(x,y2)=0
    grnden=grnden+1
  end if
next x
y2=y2+1
next y
grnden=grnden-1
for a=1 to plbul
 pbs(a)=0
next a
'#######################
'## Reset Airmines!=- ##
'#######################
for a=1 to airmines
  amx(a)=ran(640)
  amy(a)=-100-ran(900)
  ams(a)=0
next a
'plx=plx*128
'ply=ply*32
'######################
'## The Game loop!=- ##
'######################
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
repeat
gen=gen+.1
gosub dubuf
'##############################
'## Pause function part 2!=- ##
'##############################
if c=8 then
    pause .3
    repeat
    until (peek("port1")<>0)
end if
'#########################################################
'## Collision Management Variable! Collision checks for ##
'## Bullets and enemys are *NOT* done each frame, they  ##
'## Are rotated and done on alternate frames for speed. ##
'## Makes it possible to have a LOT more stuff going on ##
'#########################################################
gosub drawlevelblocks
colman=colman+1
if colman=4 colman=1
gosub controller
gosub drawman
gosub playershot
gosub drawgrounden
gosub groundfire
gosub drawairmines
gosub shot_mine_collision
if colman=1 gosub shots_grounden_collision
if colman=2 gosub grounden_player_collision
if colman=3 gosub player_mine_collision
gosub scorepanel
gosub endchecks

'#############################
'## Pause Function Part 1=- ##
'#############################

if c=8 then
  setrgb 1,255,255,255
  text 190,220,"PAUSED ANY KEY TO RESTART"
end if
'#########################
'## End Of Game Loop!=- ##
'#########################
until ((dead=1) or (comp=0))
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'########################
'## Sort Out Scores!=- ##
'########################
 score=score2
 if score>high high=score
'###############################
'## End Of Outer Game Loop!=- ##
'###############################
until (dead=1)
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'###############################
'## Print Game Over Message=- ##
'###############################
for b=1 to 100 
if b<50 a=a+5
if b>50 a=a-5
   setdrawbuf dw
   dw=1-dw
   setdispbuf dw
setrgb 1,a/3,a/2,a/4
setrgb 2,a/4,a/3,a/2
setrgb 3,a/4,a/2,a/3

   gtriangle 0,0 to 640,512 to 0,512
   gtriangle 0,0 to 640,512 to 640,0

   setrgb 1,a*2,a*3,a*4
   text 265-5+ran(10),200-2+ran(4)," GAME OVER "
   text 265-5+ran(10),220-2+ran(4),"==========="
   text 265-5+ran(10),250-2+ran(4),"YOU SCORED:"
   text 265-5+ran(10),290-2+ran(4),"*  "+str$(score)+"  *"
   text 265-5+ran(10),310-2+ran(4),"==========="
next b
'##########################################
'## Return to beginning of game cycle!=- ##
'##########################################
goto start
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'   Below Are The Subroutines Called By The Main Loop!
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

'########################################################
'## check and see if any of our bullets has hit a mine ##
'########################################################
label shot_mine_collision
for a=1 to plbul
for b=1 to airmines
   if pbs(a)<>0 and ams(b)=0 then 
   if pbx(a)>=amx(b) and pbx(a)<=amx(b)+30 then
   if pby(a)>=amy(b) and pby(a)<=amy(b)+30 then
     ams(b)=1
     score2=score2+31
     pbs(a)=0
     grn=grn+180
     red=red+165
     blu=blu+145
   fi
   fi
   fi
next b
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label player_mine_collision
'######################################################
'## Checks for collisions between mines and player=- ##
'######################################################
for a=1 to airmines
if amx(a)>=plx-25 and amx(a)<=plx+15 and amy(a)>ply-40 and amy(a)<ply+10 and ams(a)=0 then
    red=red+400
    grn=grn+400
    blu=blu+400
    ams(a)=1
  energy=energy-10
end if
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label drawairmines
'#######################################
'## Draw the mines and track player=- ##
'#######################################
for a=1 to airmines
if ams(a)=0 then
setrgb 1,100,100,255
line amx(a)-10,amy(a)+10 to amx(a)+30,amy(a)+10
line amx(a)+10,amy(a)-10 to amx(a)+10,amy(a)+30
setrgb 1,50,155,50
fill rectangle amx(a)-wtr,amy(a)-wtr to amx(a)+20+wtr,amy(a)+20+wtr
setrgb 1,rc,0,0
fill rectangle amx(a)+5,amy(a)+5 to amx(a)+15,amy(a)+15
amx(a)=amx(a)-((amx(a)-(plx-10))/(80+(a*15)))
amy(a)=amy(a)-((amy(a)-(ply-15))/(80+(a*15)))
end if
if ams(a)>0 then
setrgb 1,50-ams(a),155-ams(a),50-ams(a)
rectangle amx(a)-(wtr*3),amy(a)-(wtr*3) to amx(a)+20+(wtr*3),amy(a)+20+(wtr*3)
ams(a)=ams(a)+1
if ams(a)>50 then
  amy(a)=-400-ran(600)
  ams(a)=0
end if
end if
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'#########################################################
'## Handles Ground Based Enemy Shooting and collisions! ##
'#########################################################
label groundfire
r=ran(difficult)
for a=1 to grnden
if r<20 and gms(a)=0 and gns(a)<30 then
   gms(a)=250
   gmx(a)=gnx(a)
   gmy(a)=gny(a)-20
   gmxo(a)=gnx(a)
   gmyo(a)=gny(a)
   r=1000
   red=red+10
   grn=grn+30
   blu=blu+40
end if
if gms(a)>0 then
  gms(a)=gms(a)-1
  setrgb 1,gms(a)+100,gms(a),gms(a)
  fill rectangle gmx(a)-2,gmy(a)-2 to gmx(a)+2,gmy(a)+2
  line gmx(a),gmy(a) to gmxo(a),gmyo(a)
  gmxo(a)=gmx(a)
  gmyo(a)=gmy(a)
  gmx(a)=gmx(a)-(gmx(a)-plx)/20
  gmy(a)=gmy(a)-(gmy(a)-ply+20)/20
 if gmx(a)>=plx-15 and gmx(a)<=plx+10 and gmy(a)>=ply-25 and gmy(a)<=ply then
  gms(a)=0
  energy=energy-3.5
  red=red+45
  grn=grn+45
  blu=blu+45
end if
end if
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label endchecks
'##########################################
'## is level complete? Is Player Dead?=- ##
'##########################################
    comp=50*grnden
    for a=1 to grnden
      comp=comp-gns(a)
    next a
    if energy=0 dead=1
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label grounden_player_collision
'########################################################
'## Collision between enemys and player 1! If enemy is ##
'## Damaged, it will repair itself with pl1 energy!!!! ##
'######################################################## 
for a=1 to grnden
if gns(a)<30 then
if plx>gnx(a) and plx<gnx(a)+32 then
if ply>gny(a)-32 and ply<=gny(a) then
setrgb 1,255,255,255
energy=energy-3
red=red+65
  rectangle gnx(a)-2-wts,gny(a)-34-wts to gnx(a)+34+wts,gny(a)+wts
if gns(a)>0 gns(a)=gns(a)-1
end if
end if
fi
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label shots_grounden_collision
'########################################################
'## Detect Player bullet collisions with ground enemys ##
'########################################################
for a=1 to plbul
 if pbs(a)<>0 then
   for b=1 to grnden
      if gns(b)<30 then
      if pbx(a)>=gnx(b) and pbx(a)<=gnx(b)+32 then
      if pby(a)<=gny(b) and pby(a)>=gny(b)-32 then
        gns(b)=gns(b)+3
        pbs(a)=0
        score2=score2+10
        red=red+10
        grn=grn+15
        blu=blu+25
      fi
      fi
      fi
   next b
  fi
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'#########################################################
'## Responsible for drawing and moving the ground enmys ##
'## Also For Detecting Platform Ends And Killing Tanks! ##
'#########################################################
label drawgrounden
rc=ran(255)
for a=1 to grnden
if gns(a)<30 then
'#################
'## Draw Tank=- ##
'#################
 setrgb 1,0,0,0
 fill rectangle gnx(a),gny(a)-32 to gnx(a)+32,gny(a)
 setrgb 1,120+(gns(a)*10),150-(gns(a)*3),250-(gns(a)*3)
 fill rectangle gnx(a)+1,gny(a)-5 to gnx(a)+31,gny(a)-31
 setrgb 1,rc,0,0
 fill rectangle gnx(a)+10,gny(a)-12 to gnx(a)+22,gny(a)-24
'#######################################################
'## Move the Ground enemys check for platform ends!=- ##
'#######################################################
  gnx(a)=gnx(a)+gnd(a)
  if gnx(a)>630 gnd(a)=-1
  if gnx(a)<10 gnd(a)=1
xwork=int((gnx(a)+16)/128)+1
ywork=(gny(a)/32)
'#########################################################
'## AAARRRGGHHH A Goto Kill Him! Taking This Out Causes ##
'## A Crash. It Is Unfortunately Nescessary To Avoid A  ##
'## Load Of Speed Sapping Code. There's Another Later on##
'#########################################################
if xwork=6 goto out
if curlevel(xwork,ywork+1)=0 or curlevel(xwork,ywork+1)=2 then
gnd(a)=-gnd(a)
end if
fi
'###############################
'## The Goto Jumps To Here!=- ##
'###############################
label out
'#####################################
'## Explosion! And Death Of Tank!=- ##
'#####################################
if gns(a)>=30 and gns(a)<50 then 
  setrgb 1,255-gns(a),255-gns(a),255-gns(a)
  rectangle gnx(a)-gns(a),gny(a)-32-gns(a) to gnx(a)+32+gns(a),gny(a)+gns(a)
 gns(a)=gns(a)+5
 red=red+40
 grn=grn+50
 blu=blu+50
 score2=score2+20
end if
if gns(a)>50 gns(a)=50
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'###################################################
'## Adds Player Bullet And Moves Player Bullets=- ##
'###################################################
label playershot
if shotdelay<7 shotdelay=shotdelay+1
'###############################
'## Add bullet if available=- ## 
'###############################
if fire=1 and shotdelay=7 then 
for a=1 to plbul
 if pbs(a)=0 then
   shotdelay=0
   ammo=ammo-1
red=red+25
grn=grn+25
blu=blu+25
   if face=1 then xm=xm-1+thrust : pbx(a)=plx+5 : fi
   if face=2 then xm=xm+1+thrust : pbx(a)=plx-15 : fi
   pby(a)=ply-21
   pbs(a)=face
   setrgb 1,255,245,45
  fill rectangle pbx(a)-3-ran(2),pby(a)-3-ran(2) to pbx(a)+3+ran(2),pby(a)+3+ran(2)
   a=plbul+1
  end if
next a
end if
'########################################################
'## Draw player bullets and update pos. check off scrn ##
'########################################################
for a=1 to plbul
if pbs(a)>0 then
   fill rectangle pbx(a)-2,pby(a)-2 to pbx(a)+2,pby(a)+2  
   if pbs(a)=1 pbx(a)=pbx(a)+10
   if pbs(a)=2 pbx(a)=pbx(a)-10
   if pbx(a)>640 or pbx(a)<0 pbs(a)=0
end if
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'#######################################################
'## Check Joypad and do player update/platform checks ##
'#######################################################
label controller
'32=right
'128=left
'#####################
'## Read the pad!=- ##
'#####################
c=peek("port1")
if (and(c,32)>0) then xm=3 : face=1: end if
if (and(c,128)>0) then xm=-3: face=2 : end if
if (and(c,16384)>0) and fuel>0 then thrust=1 : fuel=fuel-.1: grav=grav-.2 : end if
if (and(c,16384)=0) or fuel=0 thrust=0 
if (and(c,2048)>0) fire=1
if (and(c,2048)=0) or ammo=0 fire=0
'######################
'## Update Postion=- ##
'######################
plx=plx+xm
ply=ply+grav
if thrust=0 grav=grav+.1
if grav>5 grav=5
if grav<-5 grav=-5
if xm>0 xm=xm-.5
if xm<0 xm=xm+.5
xwork=int((plx+128)/128)
ywork=int(ply/32)+1
'####################################
'## Check for regeneration block=- ##
'####################################
if curlevel(xwork,ywork)=3 then
 blu=blu+10
 if energy<100 energy=energy+.1
 if ammo<100 ammo=ammo+.5
 if fuel<100 fuel=fuel+.2
end if
'#######################
'## Check for water=- ##
'#######################
if curlevel(xwork,ywork)=2 then
energy=energy-1
red=red+25
end if
'####################################
'## Check for blocks if falling!=- ##
'####################################
if curlevel(xwork,ywork)<>0 and curlevel(xwork,ywork)<>2 and thrust=0 and grav>=0 then
ply=((ywork-1)*32)
if grav=5 then
energy=energy-5
red=red+40
end if
grav=0
end if
'#######################
'## Limit boundarys!=-##
'#######################
if ply>442 then grav=0 : ply=440 : end if
if ply<=10 grav=grav+2
if plx>630 plx=630
if plx<10 plx=10
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'#############################
'## Draw our little chap!=- ##
'#############################
label drawman
 setrgb 1,100,100,100
  fill rectangle plx-10,ply to plx,ply-32
 if face=1 then
  setrgb 1,0,0,0
  fill rectangle plx,ply-30 to plx-5,ply-26
  fill rectangle plx-10,ply to plx+2,ply-3
  line plx-3,ply-2 to plx-3,ply-15
  setrgb 1,90,90,40
  fill rectangle plx-10,ply-25 to plx-15,ply-15
if thrust=1 then
   setrgb 1,wtr*20,wtr*30,0
   fill rectangle plx-10,ply-15 to plx-15,ply-10+ran(4)
fi
  setrgb 1,50,50,50
  fill rectangle plx-8,ply-15 to plx-3,ply-25
  fill rectangle plx-8,ply-15 to plx+2,ply-20
  setrgb 1,200,200,200
  fill rectangle plx,ply-20 to plx+4,ply-22
 end if
 if face=2 then
  setrgb 1,0,0,0
  fill rectangle plx-10,ply-30 to plx-5,ply-26
  fill rectangle plx-13,ply to plx,ply-3
  line plx-7,ply-2 to plx-7,ply-15
  setrgb 1,90,90,40
  fill rectangle plx,ply-25 to plx+5,ply-15
if thrust=1 then
   setrgb 1,wtr*20,wtr*30,0
   fill rectangle plx,ply-15 to plx+5,ply-10+ran(4)
fi
  setrgb 1,50,50,50
  fill rectangle plx-8,ply-15 to plx-3,ply-25
  fill rectangle plx-3,ply-15 to plx-12,ply-20
  setrgb 1,200,200,200
  fill rectangle plx-10,ply-20 to plx-14,ply-22
 end if
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'#####################################
'## Draw the in game score panel!=- ##
'#####################################
label scorepanel
if energy<0 energy=0
if ammo<0 ammo=0
if fuel<0 fuel=0
if score<score2 score=score+1
setrgb 1,50,50,100
fill rectangle 110,471 to 220,457
setrgb 1,255,255,255
text 110,468,str$(score)
rectangle 372,457 to 572,470
rectangle 372,477 to 572,490
rectangle 372,497 to 572,510
setrgb 1,0,0,0
fill rectangle 373,458 to 572,470
fill rectangle 373,478 to 572,490
fill rectangle 373,498 to 572,510
setrgb 1,255,0,0
fill rectangle 373,458 to 372+(energy*2),470
fill rectangle 373,478 to 372+(ammo*2),490
fill rectangle 373,498 to 372+(fuel*2),510
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'########################
'## Draws the level!=- ##
'########################
label drawlevelblocks
'#################################
'## Draw The Starfield First!=- ##
'#################################
for a=1 to nstr
setrgb 1,40,40,40*sts(a)
fill rectangle stx(a),sty(a) to stx(a)+sts(a),sty(a)+sts(a)
stx(a)=stx(a)+sts(a)
if stx(a)>640 stx(a)=stx(a)-640
next a
'##################################
'## Then Draw the Background!!=- ##
'##################################
   setrgb 1,0,0,0
   setrgb 2,0,60,0
   setrgb 3,0,30,0
   for a=1 to 720 step 72
      gtriangle a-100,440 to a+100,440 to a,mountains((a/72)+1)
   next a
'######################
'## Now the blocks=- ##
'######################
xpos=0
ypos=0
wtr=3-3*sin(gen)
for y=1 to 14
xpos=0
for x=1 to 5
'########################################################
'## Here's The Other Goto That Saves This Routine From ##
'## Going Through All The Checks If It's An Empty Block##
'########################################################
if curlevel(x,y)=0 goto noneed
'#####################
'## Normal Block:=- ##
'#####################
  if curlevel(x,y)=1 then
       setrgb 1,85,160,130
       fill rectangle xpos,ypos to xpos+126,ypos+30
       setrgb 1,45,100,110
       fill rectangle xpos+2,ypos+2 to xpos+126,ypos+30
  end if
'###################
'## Water Block=- ##
'###################
  if curlevel(x,y)=2 then
       setrgb 1,20,60,205
       fill rectangle xpos,ypos+wtr to xpos+128,ypos+32
  end if
'######################
'## Recharge Block=- ##
'######################
  if curlevel(x,y)=3 then
       setrgb 1,130,70,60
       fill rectangle xpos,ypos to xpos+126,ypos+30
       setrgb 1,110,50,40
       fill rectangle xpos+2,ypos+2 to xpos+126,ypos+30
       setrgb 1,255,155,100
       fill triangle xpos+64,ypos+14-wtr to xpos+74,ypos+28-wtr to xpos+54,ypos+28-wtr
  end if
'###########################
'## Goto Jumps To Here!=- ##
'###########################
label noneed
  xpos=xpos+128
next x
ypos=ypos+32
next y
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label dubuf
'###########################################
'## Swaps screens Does nice background!=- ##
'###########################################
  setdrawbuf dw
  dw=1-dw
  setdispbuf dw
if red>250 red=250
if grn>250 grn=250
if blu>250 blu=250
if red>0 red=red-(red/5)
if grn>0 grn=grn-(grn/5)
if blu>0 blu=blu-(blu/5)
  setrgb 1,red+20,20,40
  setrgb 2,40,grn+20,20
  setrgb 3,20,40,blu+20
'############################################
'## Clears Game Area And NOT Scorepannel=- ##
'############################################
    gtriangle 0,0 to 640,450 to 0,450
    gtriangle 0,0 to 640,450 to 640,0
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label titlescreen
'################################################
'## This is the Simple But Nice Titlescreen!=- ##
'################################################
a=0
'#########################################################
'## To Just Do The Scroll Every Update Became Nescessary##
'## Because It wouldn't run at 50 frames/sec otherwise! ##
'## Yabasic Programs Tend To Slow Down When They Get big##
'#########################################################
for x=1 to 2
 setdrawbuf dw
 dw=1-dw
 setdispbuf dw
   setrgb 1,50,30,20
   setrgb 2,20,50,30
   setrgb 3,20,30,50
   gtriangle 0,0 to 640,512 to 0,512
   gtriangle 0,0 to 640,512 to 640,0
  setrgb 1,10,10,20
  fill rectangle 110,60 to 550,472
  setrgb 1,30,40,110
  fill rectangle 100,50 to 540,462
setrgb 1,255,255,255
text 100,70,"            - -=J-E-T  P-A-C=- -"
text 100,90,"           - --==============-- -"
setrgb 1,255,255,155
text 100,110," CODED BY SHOCKWAVE (NICK SIMPSON) (C) 2001"
text 100,130," =========================================="
setrgb 1,255,155,255
text 100,150,"             SOME INSTRUCTIONS:"
text 100,170,"             =================="
setrgb 1,155,155,255
text 100,190," DESTROY  ALL PLATFORM TANKS TO CLEAR LEVEL"
text 100,210,"  BEWARE OF AIR MINES AND GUIDED MISSILES"
text 100,230,"  IF YOU RUN OUT OF ENERGY.. GAME UNDER!!"
text 100,250," RECHARGE ENERGY/AMMO/FUEL ON RED PLATFORMS"
text 100,110," CODED BY SHOCKWAVE (NICK SIMPSON) (C) 2001"
text 100,130," =========================================="
text 100,270,"                THE CONTROLS:"
text 100,290,"                ============="
setrgb 1,255,155,155
text 100,310," D-PAD LEFT AND RIGHT : MOVE LEFT AND RIGHT"
text 100,330,"   PRESS (X) : ACTIVATE JETPACK (THRUST)"
text 100,350,"   PRESS (R1) : TO FIRE YOUR PULSE RIFLE"
text 100,370,"     PRESS (START) : TO PAUSE THE GAME!"
text 100,390,"     =================================="
setrgb 1,255,255,255
text 100,410," CONTACT: WWW.YABASIC.CO.UK (A GREAT SITE!)"
setrgb 1,255,155,255
text 100,430," PRESS X TO BEGIN OR READ THE MESSAGE BELOW"
setrgb 1,100,100,155
text 100,488,"LAST GAME SCORED:"+str$(score)
text 100,508,"TODAYS HIGHEST SCORE:"+str$(high)
next x
'###########################
'## Just Do The Scroll!=- ##
'###########################
repeat
 setdrawbuf dw
 dw=1-dw
 setdispbuf dw
setrgb 1,30,40,100
fill rectangle 100,462 to 530,442
setrgb 1,100,100,200
text scx,455,mid$(s$,p,43)
scx=scx-2
setrgb 1,30,40,110
fill rectangle 100,462 to 115,442
fill rectangle 540,462 to 530,442
if scx<100 then
   scx=scx+10
   p=p+1
   if p>len(s$) p=0
end if
until (peek("port1")=16384)
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label drawscorepanel
'######################################################
'## Draws as much of the text as possible beforehand ##
'## to stop slowdown!=-                              ##
'######################################################
for a=1 to 3
setrgb 1,50,50,100
fill rectangle 0,450 to 640,512
setrgb 1,255,255,255
text 50,467,"SCORE:"
text 50,487,"LEVEL:"+str$(level)
text 50,507,"HIGH :"+str$(high)
text 300,467,"ENERGY:"
text 300,487,"  AMMO:"
text 300,507,"  FUEL:"
gosub dubuf
next a
return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
' Here Are The Levels. Make Them 5*14.
' ====================================
' Make Sure U Define A Player Block.
' Make Sure That Tanks Are Not Placed Above Empty Blocks.
' Define Up To 7 Tanks Per Level.
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'Level Data:
'0=empty block
'1=normal block
'2=water block
'3=recharge block
'6=tank
'5=player
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'Level 1:
data 0,0,0,0,0
data 0,0,0,6,6
data 6,6,0,1,1
data 1,1,0,0,0
data 0,0,0,6,0
data 6,0,0,1,0
data 1,0,0,0,0
data 0,0,0,0,1
data 6,0,0,0,0
data 1,1,0,0,0
data 0,0,0,0,0
data 0,0,0,0,0
data 5,0,0,0,0
data 3,2,2,1,2
'level 2
data 6,0,0,6,0
data 1,1,0,1,3
data 0,0,0,0,0
data 0,0,0,0,0
data 0,0,0,0,0
data 6,0,0,0,0
data 1,0,0,6,0
data 0,0,0,1,1
data 6,6,0,0,0
data 1,1,0,0,0
data 0,0,0,0,6
data 0,0,0,0,1
data 5,0,0,0,0
data 1,2,1,1,3
'level 3
data 0,0,6,6,6
data 0,0,1,1,1
data 0,0,0,0,0
data 0,0,0,0,0
data 0,0,0,0,0
data 6,6,0,6,6
data 1,1,0,1,1
data 0,0,0,0,0
data 0,0,0,0,0
data 3,1,0,0,0
data 0,0,0,0,0
data 0,0,5,0,0
data 0,0,1,0,0
data 2,2,2,2,2
'level 4
data 0,0,0,0,0
data 0,0,6,6,6
data 0,0,1,1,1
data 0,0,0,0,0
data 0,0,0,0,0
data 0,0,0,6,6
data 0,1,1,3,3
data 0,6,0,0,0
data 0,1,0,0,0
data 1,0,0,0,0
data 0,0,0,0,0
data 0,0,6,0,5
data 0,0,1,0,1
data 2,2,2,2,2
'level 5
data 0,0,0,6,0
data 0,0,1,1,1
data 0,0,0,0,0
data 0,0,0,0,0
data 0,0,0,0,0
data 0,0,0,0,6
data 0,1,1,3,3
data 0,0,0,0,0
data 0,6,6,0,0
data 1,1,1,1,0
data 0,0,0,0,0
data 0,6,6,6,5
data 0,1,1,1,1
data 2,2,2,2,2
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
' ====================
' = That's All Folks!=
' =(C) Shockwave 2001=
' ====================
' And Just to p*ss you all off, I realised that this
' listing is close to 1000 lines (sorry). It is error
' free though, although I wouldn't wanna type it, it'd
' take too long... Hang on though, I just did didn't I?
' hehe!
' =====================================================
' I Think this one is better than my PUK MAN game, it's
' certainly a lot more "Finished" There are no bugs in
' here as far as I am aware.. If you know different then
' let me know.
'
' It only frames out when it reaches it's maximum skill
' level and even then it's only slight. Simulate this by 
' changing the line difficult=1500 to difficult=100
' It also shows how hard the game can get!!! 
'
' Contact me : nicksimpson007@aol.com Bye!!     Nick :o)

