'+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'+            Computer Crisis by Gareth Bailey           +
'+                    September 2001                     +
'+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +


open window 640,512 

intro()

sub game()
label gameloop
clear window
setdrawbuf 1 - draw
:drawdisplay()
:conread()
:colision()
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
setrgb 1,0,0,0

'=====================draw the enemy======================

if level<6then
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 the 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,0,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
setrgb 1,0,150,0



'====================draw players ship====================

if (pos>460) then:pos=460:fi
if (pos<60) then:pos=60:fi
setrgb 1, 44,44, 66:setrgb 2, 44,44,66:setrgb 3, 44, 44, 66
gtriangle pos,400  to pos, 430 to (pos+20), 450
setrgb 1, 88,88,133:setrgb 2, 88, 88,133:setrgb 3, 88,88, 133
gtriangle pos,400  to pos, 430 to (pos-20), 450

if (jet=0) then
setrgb 1,255,153,51:setrgb 2,255,153,51:setrgb 3,255,153,51
fi
if (jet=1) then
setrgb 1, 150,0,0:setrgb 2, 150, 0, 0:setrgb 3, 150, 0, 0 
fi
gtriangle pos,435  to pos, 470 to (pos-5), 445
gtriangle 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=400
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 FAILED","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.5
hit=0
pos=260
msgbox()
text 320,235,"L E V E L","cc"
text 320,250,"C L E A R", "cc"
waitforx()
wait(1)
lev$=str$(level)
elsif (level=10 and hit>=0)then
wait (1)
clear window
congrats()
main()
fi
end sub


sub p()
msgbox()
text 320,230,"P A U S E D" ,"cc"
waitforx()
return
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
7
sub msgbox()
clear window
setrgb 1,0,0,0
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 intro()
ef=0
my=20
setrgb 1,0,150,0
label effect
while (ef<64)
b=int(ran(2))
b$=str$(b)
mx=mx+15

text mx,my,b$
ef=ef+1
wend
if my<490 then
my=my+15
ef=0
mx=0
goto effect
fi
setrgb 1,0,0,0
fill rectangle 220,200 to 420,300
setrgb 1,0,150,0
text 320,280,"PRESS 'X'","cc"
text 320,295,"TO CONTINUE","cc"
setrgb 1,150,0,0
text 320,215, "C O M P U T E R","cc"
text 320,245, "C R I S I S","cc"
waitforx()
wait(0.5)
main()
end sub

sub main()
setup()
label menuloop
clear window 
setdrawbuf 1 - draw
setrgb 1,0,150,0


text 320,100, "C O M P U T E R  C R I S I S","cc"
setrgb 1,0,50,0
setrgb 1,51,102,204
text 320,200, "S T A R T  G A M E ","cc"
text 320,230, "V I E W   S T O R Y","cc"
text 320,260, "V I E W   C R E D I T S","cc"
text 320,400, "PRESS 'X' TO SELECT","cc"
text 320,415,"PRESS TRIANGLE TO EXIT","cc"
setrgb 1, 44,44, 66
fill triangle 130,x1-20  to 180, x1 to  150,x1
setrgb 1, 88,88,133
fill triangle 130,x1+20  to 180, x1 to  150,x1

con = peek("port1")
if and(con, 16) <> 0 then
if option=1 then
x1=195: option=1
wait(0.2)
else
x1=x1-30: option=option-1
wait(0.2)
fi
elsif and(con, 64) <> 0 then
if option=3 then
x1=255: option=3
wait(0.2)
else
x1=x1+30: option=option+1
wait(0.2)
fi

elsif and(con, 4096) <> 0 then
end
elsif and(con, 16384) <> 0 then
if (option=0) then
option=1
elsif (option=4) then
option=3
fi
if (option=1) then
game()
elsif (option=2)then
story()
elsif (option=3) then
credits()
fi
fi
setdispbuf draw
draw = 1 - draw
goto menuloop
end sub

sub credits()
setrgb 1,51,102,204
clear window
cx=640
cy=500
zx=0
repeat
clear window
setdrawbuf 1 - draw
text cx,100,"ORIGINAL DESIGN: Gareth Bailey"
cx=cx-5
setdispbuf draw
draw = 1 - draw
until (cx=20)
repeat

clear window
setdrawbuf 1 - draw
text cx,100,"ORIGINAL DESIGN: Gareth Bailey"
text 20,cy,"PROGRAMING     : Gareth Bailey"
cy=cy-5
setdispbuf draw
draw = 1 - draw
until (cy=115)
setdrawbuf 1-draw
text cx,100,"ORIGINAL DESIGN: Gareth Bailey"
text 20,cy,"PROGRAMING     : Gareth Bailey"
setrgb 1,0,50,0
circle 340,365,15
line 340,345 to 340,385
line 320,365 to 360,365
setrgb 1,255,0,0
text 150,350,"C O M P U T E R"
text 210,380,"C R I S I S"
waitforx()
wait 0.5
main()
end sub

sub story()
setrgb 1,0,150,0
clear window
text 20,100,"The year is 2025 and the world is about to be changed, a new"
text 20,130,"type of virus has emerged and is about to cause virtual"
text 20,160,"destruction.  It behaves like a living being seeking out"
text 20,190,"vunreable targets, much infomation will be lost causeing "
text 20,220,"caos.  Some how you are transeported into cyberspace where"
text 20,250,"you can destroy the viruses and hopefull stop them. You"
text 20,280,"  have to stop them..."
setrgb 1,0,50,0
circle 340,365,15
line 340,345 to 340,385
line 320,365 to 360,365
setrgb 1,255,0,0
text 150,350,"C O M P U T E R"
text 210,380,"C R I S I S"
wait (1)
waitforx()
wait(0.5)
end sub

sub congrats()
clear window
setrgb 1,0,255,0
for a=0 to 3
text 20,100,"The the world is now safe, You have concured the viruses that": wait 0.2
setrgb 1,0,0,0
text 20,100,"The the world is now safe, You have concured the viruses that": wait 0.2
setrgb 1,0,255,0
next a
for a=0 to 3
setrgb 1,0,255,0
text 20,130,"threatend to destroy the world as we know it.  You can now": wait 0.2
setrgb 1,0,0,0
text 20,130,"threatend to destroy the world as we know it.  You can now": wait 0.2
setrgb 1,0,255,0
next a
for a=0 to 3
setrgb 1,0,255,0
text 20,160,"return to your daily life, until the next time...":wait 0.2
setrgb 1,0,0,0
text 20,160,"return to your daily life, until the next time...":wait 0.2
next a
setrgb 1,0,50,0
circle 340,365,15
line 340,345 to 340,385
line 320,365 to 360,365
setrgb 1,255,0,0
text 150,350,"C O M P U T E R"
text 210,380,"C R I S I S"
waitforx()
wait 0.5
main()
end sub








