'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~ Computer Crisis By Gareth Bailey (c) September 2001. ~ '~ A program by JINX ~ '~======================================================== ~ '~ LEFT/RIGHT to move the ship ~ '~ (X) to fire ~ '~ ~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ open window 640,512 main() sub game() label gameloop clear window setdrawbuf 1-draw drawdisplay() conread() collision() setdispbuf draw draw=1-draw goto gameloop end sub sub drawdisplay() '============draw the background=========== setrgb 1,20,20,20 fill rectangle 40,0 to 480,512 setrgb 1,0,150,0 setrgb 2,20,20,20 setrgb 3,20,20,20 gtriangle 40,512 to 40,450 to 480,450 setrgb 2,0,150,0 gtriangle 40,512 to 480,512 to 480,450 line 40,0 to 40,512 line 80,0 to 80,512 line 120,0 to 120,512 line 160,0 to 160,512 line 200,0 to 200,512 line 240,0 to 240,512 line 280,0 to 280,512 line 320,0 to 320,512 line 360,0 to 360,512 line 400,0 to 400,512 line 440,0 to 440,512 line 480,0 to 480,512 line 40,50 to 480,50 line 40,100 to 480,100 line 40,150 to 480,150 line 40,200 to 480,200 line 40,250 to 480,250 line 40,300 to 480,300 line 40,350 to 480,350 line 40,400 to 480,400 line 40,450 to 480,450 '=====Draw the enemy===== if (level<6) then setrgb 1,0,150,0 elsif (level>=6) then setrgb 1,150,0,0 fi if (virus=1) then direction=int(ran(2)) if (direction=1) then dirx=-2 elsif (direction=0)then dirx=2 fi vx=int(ran(410)) vx=vx+55 vy=0 virus=2 bonus=150 fi if (virus=2) then if (level>=6) then vx=vx+dirx fi vy=vy+speed fill circle vx,vy,15 fi '======draw bullets===== setrgb 1,250,0,0 if( shoot=1) then y=400:x=pos circle x,y,6 shoot=2 elsif (shoot=2) then y=y-10 fill circle x,y,3 fi '=======draw player stats===== setrgb 1,0,150,0 line 490,130 to 620,130 line 490,200 to 620,200 line 490,290 to 620,290 line 490,375 to 620,375 setrgb 1,150,0,0 text 490,120,"S C O R E" text 490,190,"E N E R G Y" text 490,280,"L I F E" text 490,365,"L E V E L" setrgb 1,o,150,0 text 490,150,score$ text 490,395,lev$ text 535,330,"X"+life$ setrgb 1,0,50,0 if (energy<530) then setrgb 1,50,0,0 fi fill rectangle 490,220 to energy,240 setrgb 1,0,50,0 rectangle 490,220 to 620,240 setrgb 1,44,44,66 fill triangle 510,300 to 510,325 to 520,335 setrgb 1,88,88,133 fill triangle 510,300 to 510,325 to 500,335 '=====Draw players ship====== if (pos>460) then pos=460 fi if (pos<60) then pos=60 fi setrgb 1,44,44,66 fill triangle pos,400 to pos,430 to (pos+20),450 setrgb 1,88,88,133 fill triangle pos,400 to pos,430 to (pos+20),450 if (jet=0) then setrgb 1,255,153,51 elsif (jet=1) then setrgb 1,150,0,0 fi fill triangle pos,435 to pos,470 to (pos+5),445 fill triangle pos,435 to pos,470 to (pos-5),445 jet=1-jet end sub sub conread() con=peek("port1") if (and(con,128)<>0) then pos=pos-6 elsif (and(con,32)<>0) then pos=pos+6 elsif((and(con,16384)<>0) and shoot=0) then shoot=1 elsif (and(con,8)<>0) then p() fi if ((and(con,128)<>0) and (and(con,16384)<>0) and shoot=0) then shoot=1 fi if ((and(con,32)<>0) and (and(con,16384)<>0) and shoot=0) then shoot=1 fi end sub sub colision() if (x>(vx-15) and x<(vx+15) and y>(vy-15) and y<(vy+15)) then virus=1 hit=hit+1 level() score=score+(100+bonus) shoot=0 y=512 fi if (vy>500) then energy=energy-20 virus=1 fi if (energy<=490) then die() fi if (pos>(vx-15) and pos<(vx+15) and (vy-15)<400 and (vy+15)>400) then energy=energy-10 virus=1 fi if (pos+20>(vx-15) and pos+20<(vx+15) and (vy-15)<450 and (vy+15)>450) then energy=energy-10 virus=1 fi if (pos-20>(vx-15) and pos-20<(vx+15) and (vy-15)<450 and (vy+15)>450) then energy=energy-10 virus=1 fi if (y<=0) then shoot=0 y=512 fi if (vx<55) then dirx=2 elsif (vx>465) then dirx=-2 fi '=====bonus===== if (bs=1) then bonus=bonus-1 fi bs=1-bs end sub sub die() life=life-1 life$=str$(life) energy=620 hit=0 if (life=0) then msgbox() text 320,235,"G A M E O V E R","cc" waitforx() wait(1) main() fi msgbox() text 320,215,"E N E R G Y L O W","cc" text 320,245,"YOU HAVE FALED","cc" text 320,260,"TRY AGAIN","cc" waitforx() wait(1) end sub sub level() score$=str$(score) if (level<10 and hit=10) then level=level+1 speed=speed+0.75 hit=0 pos=260 msgbox() text 320,235,"LEVEL","cc" text 320,250,"CLEAR","cc" waitforx() wait(1) lev$=str$(level) elsif (level=10 and hit=10) then wait(1) clear window setrgb 1,51,102,204 text 320,100,"Well done you have destroyed all ","cc" text 320,115,"Threats to you and the rest of the ","cc" text 320,130,"world. Your mission is complete. ","cc" waitforx() wait(1) main() fi end sub sub p() msgbox() text 320,230,"P A U S E D","cc" waitforx() end sub sub waitforx() if and(peek("port1"), 16384)=0 then waitforx() fi end sub sub setup() life=3:level=1:pos=260 draw=0:jet=0:speed=3 virus=1:score=0:hit=0 bonus=100:energy=620:x1=195 bs=0:a=1:option=1 life$=str$(life) score$=str$(score) lev$=str$(level) end sub sub msgbox() clear window setrgb 1,0,150,0 rectangle 220,200 to 420,300 text 320,280," PRESS 'X'","cc" text 320,295,"TO CONTINUE","cc" end sub sub main() setup() clear window setrgb 1,0,50,0 circle 395,115,15 line 395,95 to 395,135 line 415,115 to 375,115 setrgb 1,255,0,0 text 280,100,"C O M P U T E R","cc" text 280,120," C R I S I S","cc" setrgb 1,51,102,204 text 320,220,"P R E S S (X) T O","cc" text 320,250,"S T A R T G A M E","cc" text 320,400,"PROGRAMED BY","cc" text 320,415,"GARETH BAILEY","cc" waitforx() game() end sub