sync on
sync rate 20
 
 
set display mode 600,400,16
set text font ("courier")
basesize=16
largesize=20
smallsize=10
set text size basesize
 
ink rgb(0,255,0),rgb(0,0,0)
 
count=0
while text width(s$)< screen width()
s$=s$+"0"
count=count+1
endwhile
 
width=count-1
 
cwidth=text width("0")
cheight=text height ("0")
 
height=(screen height()/cheight)-2
 
set text size largesize
pulseoffset=(text width("0")-cwidth)/2
set text size basesize
 
set text size smallsize
virusoffset=(text width("0")-cwidth)/2
set text size basesize
 
dim lines$(width,height)
 
youx=width/2
youy=height
dim pulsex(0)
dim pulsey(0)
pulses=0
dim virusx(0)
dim virusy(0)
dim virushealth(0)
viruses=0
dim civx(0)
dim civy(0)
dim civhealth(0)
civs=0
 
youhealth=255
 
refresh=0
virmove=0
civmove=0
virspeed=5
start=timer()
score=0
addscore=0
addtime=0
noscore=0
prevtime=0
 
do
 
  cls
 
  time=((timer()-start)/100)
  if time>100
    if time>200
      if time>400
        if time>600
          if time>900
            if time>1200
              if time>1800
              else
                virspeed=1
              endif
            else
              virspeed=2
            endif
          else
            virspeed=3
          endif
        else
          virspeed=4
        endif
      else
        virspeed=5
      endif
    else
      virspeed=6
    endif
  else
    virspeed=7
  endif
  atxt$=""
  if noscore>0 then noscore=noscore-(time-prevtime)
  if addtime>0
    atxt$=" +"+str$(addscore)
    addtime=addtime-(time-prevtime)
  endif
 
  if time>prevtime
    if noscore=0 then score=score+(time-prevtime)
    prevtime=time
  endif
 
  txt$="Score: "+str$(score)+atxt$
 
  if noscore>0 then txt$="NO SCORE"
  ink rgb(255,255,255),rgb(0,0,0)
  text cwidth*2,cheight*(height+1),txt$
  text cwidth*(width-18),cheight*(height+1),"HEALTH: "+str$(int(((youhealth-100.0)/155.0)*100.0))+"%"
  if spacekey()=0
    if (leftkey()) AND (youx>1)
    youx=youx-1
    endif
 
    if (rightkey()) AND (youx<width-1)
    youx=youx+1
    endif
 
    if (upkey()) AND (youy>3)
    youy=youy-1
    endif
 
    if (downkey()) AND (youy<height)
    youy=youy+1
    endif
  endif
 
  keyspace=0
  if spacekey()
    if space=0 then keyspace=1
    space=1
  else
  space=0
  endif
 
  if spacekey() AND (pulses<10)
    array insert at bottom pulsex()
    array insert at bottom pulsey()
    pulses=pulses+1
    pulsex(pulses)=youx
    pulsey(pulses)=youy-2
 
  endif
 
  if (viruses<5) AND (rnd(50+(7*virspeed))=1)
    array insert at bottom virusx()
    array insert at bottom virusy()
    array insert at bottom virushealth()
    viruses=viruses+1
    virusx(viruses)=rnd(width-2)+1
    virusy(viruses)=1
    virushealth(viruses)=255
  endif
 
  if (civs<5) AND (rnd(50+(7*virspeed))=1)
    array insert at bottom civx()
    array insert at bottom civy()
    array insert at bottom civhealth()
    civs=civs+1
    civx(civs)=rnd(width-2)+1
    civy(civs)=1
    civhealth(civs)=255
  endif
 
  if virmove>virspeed
    virmove=0
    for count=1 to viruses
      select rnd(2)
        case 0
          if virusx(count)>1 then virusx(count)=virusx(count)-1
        endcase
        case 1
          if virusx(count)<width-1 then virusx(count)=virusx(count)+1
        endcase
      endselect
          if sqrt(((virusx(count)-youx)*(virusx(count)-youx))+((virusy(count)-youy)*(virusy(count)-youy)))<20
            if virusx(count)>youx then youx=youx+1
            if virusx(count)<youx then youx=youx-1
            if virusy(count)>youy then youy=youy+1
            if virusy(count)<youy then youy=youy-1
            if (youy>virusy(count)-3) AND (youy<virusy(count)+3)
              if (youx>virusx(count)-3) AND (youx<virusx(count)+3)
                youhealth=youhealth-4
              endif
            endif
          endif
      virusy(count)=virusy(count)+1
    next count
  endif
 
  if civmove>5
    civmove=0
    for count=1 to civs
      for countb=1 to viruses
        if sqrt(((civx(count)-virusx(countb))*(civx(count)-virusx(countb)))+((civy(count)-virusy(countb))*(civy(count)-virusy(countb))))<20
          if virusx(countb)>civx(count) then civx(count)=civx(count)+1
          if virusx(countb)<civx(count) then civx(count)=civx(count)-1
          if virusy(countb)>civy(count) then civy(count)=civy(count)+1
          if virusy(countb)<civy(count) then civy(count)=civy(count)-1
          if (civy(count)>virusy(countb)-3) AND (civy(count)<virusy(countb)+3)
            if (civx(count)>virusx(countb)-3) AND (civx(count)<virusx(countb)+3)
              civhealth(count)=civhealth(count)-20
            endif
          endif
        endif
      next countb
      civy(count)=civy(count)+1
    next count
  endif
 
  ink rgb(0,255,0),rgb(0,0,0)
  if refresh>6
    for county=0 to height
      line$=""
      for countx=0 to width
        c$=str$(int(rnd(2)-0.01))
        line$=line$+c$
        lines$(countx,county)=c$
      next countx
      text 0,county*cheight,line$
    next county
    refresh=0
  else
    for county=0 to height
      line$=""
      for countx=0 to width
        line$=line$+lines$(countx,county)
      next countx
      text 0,county*cheight,line$
    next county
  endif
 
  for count=1 to civs
    if civy(count)<height-1
      ink rgb(0,0,0),rgb(0,0,0)
 
      box ((civx(count)-1)*cwidth),((civy(count)-1)*cheight),((civx(count)+2)*cwidth),((civy(count)+2)*cheight)
 
        ink rgb((100.0/255.0)*civhealth(count),200,civhealth(count)),rgb(0,0,0)
 
        text (civx(count)-1)*cwidth,(civy(count)-1)*cheight,lines$(civx(count)-1,civy(count)-1)
        text (civx(count)-1)*cwidth,(civy(count))*cheight,lines$(civx(count)-1,civy(count))
        text (civx(count)-1)*cwidth,(civy(count)+1)*cheight,lines$(civx(count)-1,civy(count)+1)
        text (civx(count)+1)*cwidth,(civy(count)-1)*cheight,lines$(civx(count)-1,civy(count)-1)
        text (civx(count)+1)*cwidth,(civy(count))*cheight,lines$(civx(count)-1,civy(count))
        text (civx(count)+1)*cwidth,(civy(count)+1)*cheight,lines$(civx(count)-1,civy(count)+1)
 
        ink rgb((100.0/255.0)*civhealth(count),100,civhealth(count)),rgb(0,0,0)
        text civx(count)*cwidth,(civy(count)-1)*cheight,lines$(civx(count),civy(count)-1)
        text civx(count)*cwidth,(civy(count))*cheight,lines$(civx(count),civy(count))
        text civx(count)*cwidth,(civy(count)+1)*cheight,lines$(civx(count),civy(count)+1)
 
        set text size basesize
        if civhealth(count)<0
          array delete element civx(),count
          array delete element civy(),count
          array delete element civhealth(),count
          civs=civs-1
          count=count-1
          noscore=50
 
        endif
    else
      array delete element civx(),count
      array delete element civy(),count
      array delete element civhealth(),count
      civs=civs-1
      count=count-1
    endif
  next count
 
  for count=1 to viruses
    if virusy(count)<height-1
      ink rgb(0,0,0),rgb(0,0,0)
      box ((virusx(count))*cwidth),((virusy(count)-1)*cheight),((virusx(count)+1)*cwidth),((virusy(count))*cheight)
      box ((virusx(count)-1)*cwidth),((virusy(count))*cheight),((virusx(count)+2)*cwidth),((virusy(count)+1)*cheight)
      box ((virusx(count))*cwidth),((virusy(count)+1)*cheight),((virusx(count)+1)*cwidth),((virusy(count)+2)*cheight)
      ink rgb(255,255-virushealth(count),255-virushealth(count)),rgb(0,0,0)
      set text size smallsize
      text ((virusx(count))*cwidth)-virusoffset,(virusy(count)-1)*cheight,lines$(virusx(count),virusy(count)-1)
      text ((virusx(count)-1)*cwidth)-(virusoffset*3),(virusy(count))*cheight,lines$(virusx(count)-1,virusy(count))+lines$(virusx(count),virusy(count))+lines$(virusx(count)+1,virusy(count))
      text ((virusx(count))*cwidth)-virusoffset,(virusy(count)+1)*cheight,lines$(virusx(count),virusy(count)+1)
      set text size basesize
      if virushealth(count)<0
        array delete element virusx(),count
        array delete element virusy(),count
        array delete element virushealth(),count
        viruses=viruses-1
        count=count-1
        if noscore=0
          addscore=500
          score=score+500
          addtime=10
        endif
      endif
    else
      array delete element virusx(),count
      array delete element virusy(),count
      array delete element virushealth(),count
      viruses=viruses-1
      count=count-1
    endif
  next count
 
  for count=1 to pulses
    if pulsey(count)>0
      ink rgb(0,0,0),rgb(0,0,0)
      box ((pulsex(count)-1)*cwidth),((pulsey(count)-1)*cheight),((pulsex(count)+2)*cwidth),((pulsey(count))*cheight)
      ink rgb(150,255,150),rgb(0,0,0)
      set text size largesize
      text ((pulsex(count)-1)*cwidth)-(pulseoffset*3),(pulsey(count)-1)*cheight,lines$(pulsex(count)-1,pulsey(count)-1)+lines$(pulsex(count),pulsey(count)-1)+lines$(pulsex(count)+1,pulsey(count)-1)
      set text size basesize
 
      hittingvirus=0
      for countb=1 to viruses
        if (pulsey(count)>virusy(countb)-4) AND (pulsey(count)<virusy(countb)+3)
          if (pulsex(count)>virusx(countb)-3) AND (pulsex(count)<virusx(countb)+3)
            hittingvirus=1
            array delete element pulsex(),count
            array delete element pulsey(),count
            pulses=pulses-1
            count=count-1
            virushealth(countb)=virushealth(countb)-30
          endif
        endif
      next countb
 
      if hittingvirus=0
        for countb=1 to civs
          if (pulsey(count)>civy(countb)-3) AND (pulsey(count)<civy(countb)+2)
            if (pulsex(count)>civx(countb)-3) AND (pulsex(count)<civx(countb)+3)
              array delete element pulsex(),count
              array delete element pulsey(),count
              pulses=pulses-1
              count=count-1
              civhealth(countb)=civhealth(countb)-15
            endif
          endif
        next countb
      endif
 
      pulsey(count)=pulsey(count)-1
    else
      array delete element pulsex(),count
      array delete element pulsey(),count
      pulses=pulses-1
      count=count-1
    endif
  next count
 
    ink rgb(0,0,0),rgb(0,0,0)
 
    box ((youx-1)*cwidth),((youy-1)*cheight),((youx+2)*cwidth),((youy+1)*cheight)
 
    ink rgb((100.0/255.0)*youhealth,255,(100.0/255.0)*youhealth),rgb(0,0,0)
    text (youx-1)*cwidth,(youy-1)*cheight,lines$(youx-1,youy-1)
    ink rgb((180.0/255.0)*youhealth,255,(180.0/255.0)*youhealth),rgb(0,0,0)
    text youx*cwidth,(youy-1)*cheight,lines$(youx,youy-1)
    ink rgb((100.0/255.0)*youhealth,255,(100.0/255.0)*youhealth),rgb(0,0,0)
    text (youx+1)*cwidth,(youy-1)*cheight,lines$(youx+1,youy-1)
    ink rgb((180.0/255.0)*youhealth,255,(180.0/255.0)*youhealth),rgb(0,0,0)
    text (youx-1)*cwidth,youy*cheight,lines$(youx-1,youy)
    ink rgb(youhealth,255,youhealth),rgb(0,0,0)
    text youx*cwidth,youy*cheight,lines$(youx,youy)
    ink rgb((180.0/255.0)*youhealth,255,(180.0/255.0)*youhealth),rgb(0,0,0)
    text (youx+1)*cwidth,youy*cheight,lines$(youx+1,youy)
 
 
 
  refresh=refresh+1
  virmove=virmove+1
  civmove=civmove+1
 
  if youhealth<100
    set text size 30
    ink rgb(255,255,255),rgb(0,0,0)
    text (screen width()/2)-(text width("GAME OVER")/2),(screen height()/2)-text height("GAME OVER")-5,"GAME OVER"
    text (screen width()/2)-(text width("PRESS ANY KEY TO QUIT")/2),(screen height()/2)+text height("PRESS ANY KEY TO QUIT")+5,"PRESS ANY KEY TO QUIT"
    sync
    wait key
    end
 
  endif
 
  sync
 
 
loop