sync on:sync rate 100:hide mouse
box 0,0,10,10:get image 1,0,0,10,10:get image 2,0,0,6,6:get image 3,0,0,3,3
enemy_max=15
dim enemy(enemy_max,4)
for i=1 to enemy_max
enemy(i,1)=0 :`alive flag - not used yet
enemy(i,2)=0 :`firing flag - used
enemy(i,3)=0 :`turret sprite - not used yet
enemy(i,4)=45 :`turret sprite angle - used
sprite i,i*40,240,1
offset sprite i,getoffset("x",1),getoffset("y",1)
next i
missile_life=200
missile_speed_df=2
missile_speed=2
missile_total=20
dim missiles(enemy_max,missile_total,4)
for i=1 to enemy_max
for i2=1 to missile_total
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
missiles(i,i2,3)=49+count
missiles(i,i2,4)=2
inc count,1
next i2
next i
sprite 9998,mousex(),mousey(),3
offset sprite 9998,getoffset("x",3),getoffset("y",3)
do
sprite 9998,mousex(),mousey(),3
if rnd(20)=1
who=1+rnd(enemy_max-1)
enemy(who,2)=1
endif
for i=1 to enemy_max
temp=enemy(i,4)+3
enemy(i,4)=wrapvalue(temp)
rotate sprite i,enemy(i,4)
burst=1+(rnd(missile_total-1))
next i
for i=1 to enemy_max
if enemy(i,2)=1
for i2=1 to burst
if missiles(i,i2,1)=0
missiles(i,i2,1)=1
if sprite exist(missiles(i,i2,3))=1 then delete sprite missiles(i,i2,3)
sprite missiles(i,i2,3),sprite x(i),sprite y(i),missiles(i,i2,4)
offset sprite missiles(i,i2,3),getoffset("x",missiles(i,i2,4)),getoffset("y",missiles(i,i2,4))
rotate sprite missiles(i,i2,3),enemy(i,4)
show sprite missiles(i,i2,3)
exit
endif
next burst
endif
next i
for i=1 to enemy_max
for i2=1 to missile_total
if missiles(i,i2,1)=1
move sprite missiles(i,i2,3),missile_speed
dec missiles(i,i2,2),1
`basic col test
if sprite collision(9998,missiles(i,i2,3))=1 then text 320,440,"ARRGHGHGH!!"
if missiles(i,i2,2)=0
hide sprite missiles(i,i2,3)
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
enemy(i,2)=0
delete sprite missiles(i,i2,3)
endif
endif
next i2
next i
sync
loop
function getoffset(xory$,image)
if sprite exist(9999)=1 then delete sprite 9999
sprite 9999,0,0,image
if xory$="x" then returnval=sprite width(9999)/2
if xory$="y" then returnval=sprite height(9999)/2
delete sprite 9999
endfunction returnval