'Yatanks by Jo morrow.
'
'
'AIM: TO BLOW THE POO OUT OF YOUR ENEMY. 
'HOLD DOWN X TO VARY THE DISTANCE OF YOUR SHOT. 
'TO DESTROY THE ENEMY, YOU MUST HIT THEM IN THEIR 
'WEAK SPOT, SO YOU'LL HAVE TO HAVE PIN POINT ACCURACY. 
'KILL 5 BADDIES TO WIN. Try and improve your time!

open window 600,480
time=0
hits=0
label draw
clear window
window origin "lb"
setrgb 1,255,255,255

if hits=0 then
text 350,435,"HITS=0"
endif
if hits=1 then
text 350,435,"HITS=1"
endif
if hits=2 then
text 350,435,"HITS=2"
endif
if hits=3 then
text 350,435,"HITS=3"
endif
if hits=4 then
text 350,435,"HITS=4"
endif

if hits>4 then
text 215,435,"MISSION COMPLETE"
wait 2
gosub winwin
endif

setrgb 1,0,0,0
fill rectangle 490-p,15 to 640,0
line 0,5 to 600,5
text 490-p,10,"ENEMY DESTROYED"
setrgb 1,255,255,255
setrgb 1,225,225,225
line 0,5 to 600,5
setrgb 1,225,225,0
text 50,9,"YOU","lb"
setrgb 1,225,225,225
fill circle 100,360,25
setrgb 1,30,10,0
fill triangle 200,5 to 240,30 to 280,5
fill triangle 295,5 to 345,40 to 395,5
fill triangle 240,5 to 290,50 to 345,5
setrgb 1,0,0,0
line 280,6 to 240,30
line 295,6 to 345,40
setrgb 1,225,150,0
fill circle 400,400,3
fill circle 360,300,3
fill circle 200,280,3
fill circle 500,100,3
fill circle 300,57,3
fill circle 97,110,3
fill circle 315,190,3  
fill circle 570,380,3
fill circle 560,280,3
fill circle 30,280,3
setrgb 1,0,200,0
rectangle 25,7 to 40,10
rectangle 28,10 to 37,15
line 38,15 to 45,20
line 30,15 to 43,22
line 42,21 to 46,20
setrgb 1,0,50,0
fill rectangle 26,6 to 39,9
fill rectangle 29,11 to 36,14
setrgb 1,255,0,255
line 10,440 to 300,440
for gauge=1 to 10
line 10+(29*gauge),440 to 10+(29*gauge),435
next gauge
gosub newenemy
inkey$ 
50 time=time+1
gosub checkeys 
inkey$
goto 50
inkey$


label newcurve
beep
setrgb 1,0,0,0
line 44,20
setrgb 1,250,250,0
for x=0 to 3.5 step 0.1: rem this loop draws a sine()-function
y=sin(x)
setrgb 1,250,250,0
circle 44+power*x,20+50*y,3
wait 0.03
setrgb 1,0,0,0
circle 44+power*x,20+50*y,3
next x
return

label explosion
REM THIS IS COLLISION DETECTION
if (44+power*x)<(566-newposition+20) and (44+power*x)>(566-newposition-20) then
gosub hit
endif
for z=0 to 20
setrgb 1,225,0,0
circle (44+power*x),10,z+3
wait 0.05
next z
setrgb 1,0,0,0
fill circle (44+power*x),10,24
setrgb 1,0,0,0
fill rectangle 10,450 to (power),455
line 10,450 to 10,450
setrgb 1,225,225,225
line 0,5 to 600,5
gosub newenemy
return

label newenemy

if hits>4 then
text 200,435,"MISSION COMPLETE"
wait 2
gosub winwin
endif

setrgb 1,0,0,0
fill rectangle 490-newposition,6 to 600-newposition,23
newposition=ran(100)
pos=newposition
for p=pos to pos
setrgb 1,250,225,0
rectangle 575-p,7 to 556-p,10
rectangle 572-p,10 to 559-p,15
line 573-p,15 to 553-p,21.5
line 558-p,15 to 549-p,21
line 549-p,21 to 553-p,21.5
setrgb 1,50,50,0
fill rectangle 576-p,6 to 555-p,9  
setrgb 1,225,0,0
text 490-p,10,"ENEMY"
setrgb 1,0,0,0
line 0,0 to 0,0
wait 0.03

setrgb 1,0,0,0
rectangle 575-p,7 to 556-p,10
rectangle 572-p,10 to 559-p,15
line 573-p,15 to 553-p,21.5
line 558-p,15 to 549-p,21
line 549-p,21 to 553-p,21.5
fill rectangle 576-p,6 to 555-p,9  
setrgb 1,0,0,0
fill rectangle 490-p,6 to 550-p,20
line 0,0 to 0,0
next p

setrgb 1,250,225,0
rectangle 575-p,7 to 556-p,10
rectangle 572-p,10 to 559-p,15
line 573-p,15 to 553-p,21.5
line 558-p,15 to 549-p,21
line 549-p,21 to 553-p,21.5
setrgb 1,50,50,0
fill rectangle 576-p,6 to 555-p,9  
setrgb 1,225,0,0
text 490-p,10,"ENEMY"
setrgb 1,0,0,0
line 0,0 to 0,0
return

label checkeys
IF PEEK("PORT1")=16384 then
gosub powermeter
gosub newcurve 
gosub explosion 
endif:return

label powermeter
setrgb 1,255,0,0
power=0
repeat
inkey$
gosub button
fill rectangle  10,450 to (power),455 
wait 0.1 
beep
until (power>0 and (peek("port1")=0)or power>300)
setrgb 1,0,0,0
line 0,0 to 0,0
return

label button
if peek("port1")=16384 then
power=power+10
endif:return

label hit
particles=100
force=10
ex=320
ey=256
set=0
dim x(particles),y(particles),xd(particles),yd(particles)
repeat
 if set=0 then
  ex=(490-p+50)
  ey=10
 fi
 gosub explode
until (and(peek("port1"),16384)<>0)
goto moop

label explode
 rf=0
 if set=0 then
  rf=1
  set=255
  for a=1 to particles
   x(a)=ex
   y(a)=ey
   xd(a)=-force+ran(force*2)
   yd(a)=-force+ran(force*2)
  next a
 fi
 if rf=1 return
 set=set-10
 if set<0 set=0
  for a=1 to particles
  setrgb 1,set,set,set
  fill rectangle x(a)-1,y(a)-1 to x(a)+ran(3),y(a)+ran(3)
  x(a)=x(a)+xd(a)
  y(a)=y(a)+yd(a)
  next a
return

label moop
if hits>4 then
text 200,435,"MISSION COMPLETE"
wait 2
gosub winwin
endif
gosub text2


label text2
hits=hits+1
clear window
setrgb 1,255,255,255
text 240,240,"WELL DONE!!!"
wait 2
gosub draw


label winwin
time=time*2+8
text 200,240,"Time taken:"+str$(time)+"Seconds"
text 160,300,"To exit press Start+Select."
text 190,350,"Try to improve your time."
79
goto 79





