sync on
sync rate 0
hide mouse
cls
global image_width
global image_height
last_frame=timer()
rem formation variables
   formation_width=10
   formation_height=5
   max_formation_height=20
   max_formation_width=30
   formation_space_x=30
   formation_space_y=30
 
alien_amount=max_formation_width*max_formation_height
 
type alien_char
   img1
   img2
   points
endtype
 
 
rem row array for alien types based on the row they are in.
dim row(max_formation_height)
 
rem image array
dim alien_char(3) as alien_char
 
for n=1 to 3
   alien_char(n).img1=n*2-1
   alien_char(n).img2=n*2
   alien_char(n).points=(4-n)^2*10
next n
 
for a=1 to 3
cls
draw_alien(a,0,0,0)
sync
get image alien_char(a).img1,1,1,image_width+1,image_height+1,1
cls
draw_alien(a,1,0,0)
sync
get image alien_char(a).img2,1,1,image_width+1,image_height+1,1
next a
cls
ink rgb(0,255,0),0
draw_gun(0,0)
sync
get image 7,1,1,image_width+1,image_height+1,1
type alien_type
   spr
   typ
   tx as float
   ty as float
   x as float
   y as float
   formx
   formy
   exist
endtype
 
rem array with all the aliens in it
dim alien(alien_amount) as alien_type
 
rem missiles
type missile_type
  x as float
  y as float
  v as float
  exist
  a as float
  side
endtype
 
global missile_amount=20
dim missile(missile_amount) as missile_type
 
global shoot_rate as float
shoot_rate=3
 
global shoot_speed as float
shoot_speed=600
 
global move_speed as float
move_speed=300
 
global missile_length=10
global missile_color
missile_color=rgb(255,0,0)
alien_speed#=4
global time#
score=0
top:
   for n=1 to formation_height
      row(n)=ceil(n*3.0/formation_height)
   next n
   clear_all_missiles()
   x=0
   y=1
   alien_amount=formation_width*formation_height
   for n=1 to alien_amount
      alien(n).spr=n
      alien(n).typ=row(y)
      inc x
      alien(n).formx=x
      alien(n).formy=y
      if x>formation_width-1
         x=0
         inc y
      endif
      sprite alien(n).spr,-100,-100,frame+1
      offset sprite alien(n).spr,sprite width(alien(n).spr)/2,sprite height(alien(n).spr)/2
      alien(n).exist=1
   next n
   n#=2400/alien_speed#
   fx#=0
   fvx#=1
   fy#=20
   px#=screen width()/2
   py#=screen height()-60
   time0=timer()
   time#=0
do
   cls
   ink rgb(255,255,255),0
   print "Score:";
   ink rgb(0,255,0),0
   print score
   time#=(timer()-time0)*0.001
   time0=timer()
   `print n#
   if timer()>last_frame+n#
      frame=1-frame
      last_frame=timer()
      dec n#,4
      if n#<100 then n#=80
      if fx#+formation_space_x*formation_width>screen width()
         fvx#=-1
         inc fy#,alien_speed#
      endif
      if fx#<0
         fvx#=1
         inc fy#,alien_speed#
      endif
      inc fx#,fvx#*alien_speed#
      shoot=rnd(5)
      alien_shoot=0
      if shoot=0
         repeat
            alien_shoot=rnd(alien_amount-1)+1
         until alien(alien_shoot).exist=1
      endif
 
   endif
   alien_count=0
   for n=1 to alien_amount
      if alien(n).exist=1
         inc alien_count
 
         alien(n).tx=fx#+formation_space_x*(alien(n).formx-0.5)
         alien(n).ty=fy#+formation_space_y*(alien(n).formy-0.5)
         alien(n).x=alien(n).tx
         alien(n).y=alien(n).ty
         if frame=0
            sprite alien(n).spr,alien(n).x,alien(n).y,alien_char(alien(n).typ).img1
         else
            sprite alien(n).spr,alien(n).x,alien(n).y,alien_char(alien(n).typ).img2
         endif
         if n=alien_shoot
            shoot_missile(alien(n).x,alien(n).y+15,shoot_speed,90,2)
            alien_shoot=0
         endif
         for m=1 to missile_amount
            if missile(m).exist=1 and missile(m).side=1 and alien(n).exist=1
               d2#=(missile(m).x-alien(n).x)^2+(missile(m).y-alien(n).y)^2
               if d2#<20^2
                  missile(m).exist=0
                  alien(n).exist=0
                  delete sprite alien(n).spr
                  score=score+alien_char(alien(n).typ).points
                  exit
               endif
            endif
         next m
      endif
   next n
   if alien_count=0
      inc formation_height,2
      inc formation_width,2
      if formation_height>max_formation_height then formation_height=max_formation_height
      if formation_width>max_formation_width then formation_width=max_formation_width
      inc alien_speed#,2
      goto top
   endif
 
   sprite 2000,px#,py#,7
   w=sprite width(2000)
   h=sprite height(2000)
   offset sprite 2000,w/2,h/2
   px#=px#+(rightkey()-leftkey())*move_speed*time#
   if px#<w/2 then px#=w/2
   if px#>screen width()-w/2 then px#=screen width()-w/2
   if spacekey()=1 and timer()>last_shot+1000.0/shoot_rate
      last_shot=timer()
      shoot_missile(px#,py#-15,shoot_speed,270,1)
   endif
      update_missiles()
   sync
loop
 
function clear_all_missiles()
   for m=1 to missile_amount
       missile(m).exist=0
   next m
endfunction
 
function update_missiles()
   ink missile_color,0
   for m=1 to missile_amount
      if missile(m).exist=1
         if missile(m).x<0 or missile(m).x>screen width() or missile(m).y<0 or missile(m).y>screen height()
            missile(m).exist=0
         else
            missile(m).y=missile(m).y+missile(m).v*sin(missile(m).a)*time#
            missile(m).x=missile(m).x+missile(m).v*cos(missile(m).a)*time#
            line missile(m).x-missile_length*0.5*cos(missile(m).a), missile(m).y-missile_length*0.5*sin(missile(m).a), missile(m).x+missile_length*0.5*cos(missile(m).a), missile(m).y+missile_length*0.5*sin(missile(m).a)
         endif
      endif
   next m
endfunction
function shoot_missile(x#,y#,v#,a#,side)
   m=0
   repeat
      inc m
   until missile(m).exist=0
   missile(m).exist=1
   missile(m).x=x#
   missile(m).y=y#
   missile(m).a=a#
   missile(m).v=v#
   missile(m).side=side
endfunction
function draw_alien(alien,frame,x,y)
if alien=1 and frame=0
   dot x+11,y+1:dot x+12,y+1:dot x+13,y+1:dot x+14,y+1
   dot x+9,y+2:dot x+10,y+2:dot x+11,y+2:dot x+12,y+2:dot x+13,y+2:dot x+14,y+2:dot x+15,y+2:dot x+16,y+2
   dot x+8,y+3:dot x+9,y+3:dot x+10,y+3:dot x+11,y+3:dot x+12,y+3:dot x+13,y+3:dot x+14,y+3:dot x+15,y+3:dot x+16,y+3:dot x+17,y+3
   dot x+7,y+4:dot x+8,y+4:dot x+9,y+4:dot x+10,y+4:dot x+11,y+4:dot x+12,y+4:dot x+13,y+4:dot x+14,y+4:dot x+15,y+4:dot x+16,y+4:dot x+17,y+4:dot x+18,y+4
   dot x+6,y+5:dot x+7,y+5:dot x+8,y+5:dot x+9,y+5:dot x+10,y+5:dot x+11,y+5:dot x+12,y+5:dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5:dot x+19,y+5
   dot x+5,y+6:dot x+6,y+6:dot x+7,y+6:dot x+8,y+6:dot x+11,y+6:dot x+12,y+6:dot x+13,y+6:dot x+14,y+6:dot x+17,y+6:dot x+18,y+6:dot x+19,y+6:dot x+20,y+6
   dot x+5,y+7:dot x+6,y+7:dot x+7,y+7:dot x+8,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+17,y+7:dot x+18,y+7:dot x+19,y+7:dot x+20,y+7
   dot x+5,y+8:dot x+6,y+8:dot x+7,y+8:dot x+8,y+8:dot x+9,y+8:dot x+10,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+15,y+8:dot x+16,y+8:dot x+17,y+8:dot x+18,y+8:dot x+19,y+8:dot x+20,y+8
   dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9
   dot x+7,y+10:dot x+8,y+10:dot x+9,y+10:dot x+11,y+10:dot x+12,y+10:dot x+13,y+10:dot x+14,y+10:dot x+16,y+10:dot x+17,y+10:dot x+18,y+10
   dot x+6,y+11:dot x+7,y+11:dot x+8,y+11:dot x+11,y+11:dot x+12,y+11:dot x+13,y+11:dot x+14,y+11:dot x+17,y+11:dot x+18,y+11:dot x+19,y+11
   dot x+5,y+12:dot x+6,y+12:dot x+7,y+12:dot x+18,y+12:dot x+19,y+12:dot x+20,y+12
   dot x+5,y+13:dot x+6,y+13:dot x+7,y+13:dot x+18,y+13:dot x+19,y+13:dot x+20,y+13
   dot x+6,y+14:dot x+7,y+14:dot x+8,y+14:dot x+17,y+14:dot x+18,y+14:dot x+19,y+14
   dot x+7,y+15:dot x+8,y+15:dot x+17,y+15:dot x+18,y+15
image_width=24
image_height=15
endif
if alien=1 and frame=1
   dot x+11,y+1:dot x+12,y+1:dot x+13,y+1:dot x+14,y+1
   dot x+9,y+2:dot x+10,y+2:dot x+11,y+2:dot x+12,y+2:dot x+13,y+2:dot x+14,y+2:dot x+15,y+2:dot x+16,y+2
   dot x+8,y+3:dot x+9,y+3:dot x+10,y+3:dot x+11,y+3:dot x+12,y+3:dot x+13,y+3:dot x+14,y+3:dot x+15,y+3:dot x+16,y+3:dot x+17,y+3
   dot x+7,y+4:dot x+8,y+4:dot x+9,y+4:dot x+10,y+4:dot x+11,y+4:dot x+12,y+4:dot x+13,y+4:dot x+14,y+4:dot x+15,y+4:dot x+16,y+4:dot x+17,y+4:dot x+18,y+4
   dot x+6,y+5:dot x+7,y+5:dot x+8,y+5:dot x+9,y+5:dot x+10,y+5:dot x+11,y+5:dot x+12,y+5:dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5:dot x+19,y+5
   dot x+5,y+6:dot x+6,y+6:dot x+7,y+6:dot x+8,y+6:dot x+11,y+6:dot x+12,y+6:dot x+13,y+6:dot x+14,y+6:dot x+17,y+6:dot x+18,y+6:dot x+19,y+6:dot x+20,y+6
   dot x+5,y+7:dot x+6,y+7:dot x+7,y+7:dot x+8,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+17,y+7:dot x+18,y+7:dot x+19,y+7:dot x+20,y+7
   dot x+5,y+8:dot x+6,y+8:dot x+7,y+8:dot x+8,y+8:dot x+9,y+8:dot x+10,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+15,y+8:dot x+16,y+8:dot x+17,y+8:dot x+18,y+8:dot x+19,y+8:dot x+20,y+8
   dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9
   dot x+9,y+10:dot x+10,y+10:dot x+15,y+10:dot x+16,y+10
   dot x+8,y+11:dot x+9,y+11:dot x+10,y+11:dot x+15,y+11:dot x+16,y+11:dot x+17,y+11
   dot x+7,y+12:dot x+8,y+12:dot x+17,y+12:dot x+18,y+12
   dot x+6,y+13:dot x+7,y+13:dot x+8,y+13:dot x+9,y+13:dot x+16,y+13:dot x+17,y+13:dot x+18,y+13:dot x+19,y+13
   dot x+5,y+14:dot x+6,y+14:dot x+9,y+14:dot x+10,y+14:dot x+15,y+14:dot x+16,y+14:dot x+19,y+14:dot x+20,y+14
   dot x+5,y+15:dot x+6,y+15:dot x+9,y+15:dot x+10,y+15:dot x+15,y+15:dot x+16,y+15:dot x+19,y+15:dot x+20,y+15
image_width=24
image_height=15
endif
if alien=2 and frame=0
   dot x+6,y+1:dot x+7,y+1:dot x+18,y+1:dot x+19,y+1
   dot x+6,y+2:dot x+7,y+2:dot x+8,y+2:dot x+17,y+2:dot x+18,y+2:dot x+19,y+2
   dot x+7,y+3:dot x+8,y+3:dot x+9,y+3:dot x+16,y+3:dot x+17,y+3:dot x+18,y+3
   dot x+8,y+4:dot x+9,y+4:dot x+16,y+4:dot x+17,y+4
   dot x+6,y+5:dot x+7,y+5:dot x+8,y+5:dot x+9,y+5:dot x+10,y+5:dot x+11,y+5:dot x+12,y+5:dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5:dot x+19,y+5
   dot x+5,y+6:dot x+6,y+6:dot x+7,y+6:dot x+8,y+6:dot x+9,y+6:dot x+10,y+6:dot x+11,y+6:dot x+12,y+6:dot x+13,y+6:dot x+14,y+6:dot x+15,y+6:dot x+16,y+6:dot x+17,y+6:dot x+18,y+6:dot x+19,y+6:dot x+20,y+6
   dot x+4,y+7:dot x+5,y+7:dot x+6,y+7:dot x+7,y+7:dot x+10,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+15,y+7:dot x+18,y+7:dot x+19,y+7:dot x+20,y+7:dot x+21,y+7
   dot x+3,y+8:dot x+4,y+8:dot x+5,y+8:dot x+6,y+8:dot x+7,y+8:dot x+10,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+15,y+8:dot x+18,y+8:dot x+19,y+8:dot x+20,y+8:dot x+21,y+8:dot x+22,y+8
   dot x+2,y+9:dot x+3,y+9:dot x+4,y+9:dot x+5,y+9:dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9:dot x+20,y+9:dot x+21,y+9:dot x+22,y+9:dot x+23,y+9
   dot x+2,y+10:dot x+3,y+10:dot x+4,y+10:dot x+5,y+10:dot x+6,y+10:dot x+7,y+10:dot x+8,y+10:dot x+9,y+10:dot x+10,y+10:dot x+11,y+10:dot x+12,y+10:dot x+13,y+10:dot x+14,y+10:dot x+15,y+10:dot x+16,y+10:dot x+17,y+10:dot x+18,y+10:dot x+19,y+10:dot x+20,y+10:dot x+21,y+10:dot x+22,y+10:dot x+23,y+10
   dot x+2,y+11:dot x+3,y+11:dot x+4,y+11:dot x+5,y+11:dot x+6,y+11:dot x+7,y+11:dot x+8,y+11:dot x+9,y+11:dot x+10,y+11:dot x+11,y+11:dot x+12,y+11:dot x+13,y+11:dot x+14,y+11:dot x+15,y+11:dot x+16,y+11:dot x+17,y+11:dot x+18,y+11:dot x+19,y+11:dot x+20,y+11:dot x+21,y+11:dot x+22,y+11:dot x+23,y+11
   dot x+2,y+12:dot x+3,y+12:dot x+4,y+12:dot x+5,y+12:dot x+6,y+12:dot x+7,y+12:dot x+8,y+12:dot x+9,y+12:dot x+10,y+12:dot x+11,y+12:dot x+12,y+12:dot x+13,y+12:dot x+14,y+12:dot x+15,y+12:dot x+16,y+12:dot x+17,y+12:dot x+18,y+12:dot x+19,y+12:dot x+20,y+12:dot x+21,y+12:dot x+22,y+12:dot x+23,y+12
   dot x+2,y+13:dot x+3,y+13:dot x+6,y+13:dot x+7,y+13:dot x+18,y+13:dot x+19,y+13:dot x+22,y+13:dot x+23,y+13
   dot x+2,y+14:dot x+3,y+14:dot x+6,y+14:dot x+7,y+14:dot x+8,y+14:dot x+17,y+14:dot x+18,y+14:dot x+19,y+14:dot x+22,y+14:dot x+23,y+14
   dot x+7,y+15:dot x+8,y+15:dot x+9,y+15:dot x+10,y+15:dot x+11,y+15:dot x+14,y+15:dot x+15,y+15:dot x+16,y+15:dot x+17,y+15:dot x+18,y+15
   dot x+8,y+16:dot x+9,y+16:dot x+10,y+16:dot x+11,y+16:dot x+14,y+16:dot x+15,y+16:dot x+16,y+16:dot x+17,y+16
image_width=24
image_height=16
endif
if alien=2 and frame=1
   dot x+6,y+1:dot x+7,y+1:dot x+18,y+1:dot x+19,y+1
   dot x+6,y+2:dot x+7,y+2:dot x+8,y+2:dot x+17,y+2:dot x+18,y+2:dot x+19,y+2
   dot x+2,y+3:dot x+3,y+3:dot x+8,y+3:dot x+9,y+3:dot x+16,y+3:dot x+17,y+3:dot x+22,y+3:dot x+23,y+3
   dot x+2,y+4:dot x+3,y+4:dot x+8,y+4:dot x+9,y+4:dot x+16,y+4:dot x+17,y+4:dot x+22,y+4:dot x+23,y+4
   dot x+2,y+5:dot x+3,y+5:dot x+7,y+5:dot x+8,y+5:dot x+9,y+5:dot x+10,y+5:dot x+11,y+5:dot x+12,y+5:dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5:dot x+22,y+5:dot x+23,y+5
   dot x+2,y+6:dot x+3,y+6:dot x+6,y+6:dot x+7,y+6:dot x+8,y+6:dot x+9,y+6:dot x+10,y+6:dot x+11,y+6:dot x+12,y+6:dot x+13,y+6:dot x+14,y+6:dot x+15,y+6:dot x+16,y+6:dot x+17,y+6:dot x+18,y+6:dot x+19,y+6:dot x+22,y+6:dot x+23,y+6
   dot x+2,y+7:dot x+3,y+7:dot x+4,y+7:dot x+5,y+7:dot x+6,y+7:dot x+7,y+7:dot x+10,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+15,y+7:dot x+18,y+7:dot x+19,y+7:dot x+20,y+7:dot x+21,y+7:dot x+22,y+7:dot x+23,y+7
   dot x+2,y+8:dot x+3,y+8:dot x+4,y+8:dot x+5,y+8:dot x+6,y+8:dot x+7,y+8:dot x+10,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+15,y+8:dot x+18,y+8:dot x+19,y+8:dot x+20,y+8:dot x+21,y+8:dot x+22,y+8:dot x+23,y+8
   dot x+2,y+9:dot x+3,y+9:dot x+4,y+9:dot x+5,y+9:dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9:dot x+20,y+9:dot x+21,y+9:dot x+22,y+9:dot x+23,y+9
   dot x+2,y+10:dot x+3,y+10:dot x+4,y+10:dot x+5,y+10:dot x+6,y+10:dot x+7,y+10:dot x+8,y+10:dot x+9,y+10:dot x+10,y+10:dot x+11,y+10:dot x+12,y+10:dot x+13,y+10:dot x+14,y+10:dot x+15,y+10:dot x+16,y+10:dot x+17,y+10:dot x+18,y+10:dot x+19,y+10:dot x+20,y+10:dot x+21,y+10:dot x+22,y+10:dot x+23,y+10
   dot x+3,y+11:dot x+4,y+11:dot x+5,y+11:dot x+6,y+11:dot x+7,y+11:dot x+8,y+11:dot x+9,y+11:dot x+10,y+11:dot x+11,y+11:dot x+12,y+11:dot x+13,y+11:dot x+14,y+11:dot x+15,y+11:dot x+16,y+11:dot x+17,y+11:dot x+18,y+11:dot x+19,y+11:dot x+20,y+11:dot x+21,y+11:dot x+22,y+11
   dot x+4,y+12:dot x+5,y+12:dot x+6,y+12:dot x+7,y+12:dot x+8,y+12:dot x+9,y+12:dot x+10,y+12:dot x+11,y+12:dot x+12,y+12:dot x+13,y+12:dot x+14,y+12:dot x+15,y+12:dot x+16,y+12:dot x+17,y+12:dot x+18,y+12:dot x+19,y+12:dot x+20,y+12:dot x+21,y+12
   dot x+6,y+13:dot x+7,y+13:dot x+18,y+13:dot x+19,y+13
   dot x+5,y+14:dot x+6,y+14:dot x+7,y+14:dot x+18,y+14:dot x+19,y+14:dot x+20,y+14
   dot x+4,y+15:dot x+5,y+15:dot x+6,y+15:dot x+19,y+15:dot x+20,y+15:dot x+21,y+15
   dot x+4,y+16:dot x+5,y+16:dot x+20,y+16:dot x+21,y+16
image_width=24
image_height=16
endif
if alien=3 and frame=0
   dot x+9,y+1:dot x+10,y+1:dot x+11,y+1:dot x+12,y+1:dot x+13,y+1:dot x+14,y+1:dot x+15,y+1:dot x+16,y+1
   dot x+7,y+2:dot x+8,y+2:dot x+9,y+2:dot x+10,y+2:dot x+11,y+2:dot x+12,y+2:dot x+13,y+2:dot x+14,y+2:dot x+15,y+2:dot x+16,y+2:dot x+17,y+2:dot x+18,y+2
   dot x+3,y+3:dot x+4,y+3:dot x+5,y+3:dot x+6,y+3:dot x+7,y+3:dot x+8,y+3:dot x+9,y+3:dot x+10,y+3:dot x+11,y+3:dot x+12,y+3:dot x+13,y+3:dot x+14,y+3:dot x+15,y+3:dot x+16,y+3:dot x+17,y+3:dot x+18,y+3:dot x+19,y+3:dot x+20,y+3:dot x+21,y+3:dot x+22,y+3
   dot x+2,y+4:dot x+3,y+4:dot x+4,y+4:dot x+5,y+4:dot x+6,y+4:dot x+7,y+4:dot x+8,y+4:dot x+9,y+4:dot x+10,y+4:dot x+11,y+4:dot x+12,y+4:dot x+13,y+4:dot x+14,y+4:dot x+15,y+4:dot x+16,y+4:dot x+17,y+4:dot x+18,y+4:dot x+19,y+4:dot x+20,y+4:dot x+21,y+4:dot x+22,y+4:dot x+23,y+4
   dot x+1,y+5:dot x+2,y+5:dot x+3,y+5:dot x+4,y+5:dot x+5,y+5:dot x+6,y+5:dot x+7,y+5:dot x+8,y+5:dot x+9,y+5:dot x+10,y+5:dot x+11,y+5:dot x+12,y+5:dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5:dot x+19,y+5:dot x+20,y+5:dot x+21,y+5:dot x+22,y+5:dot x+23,y+5:dot x+24,y+5
   dot x+1,y+6:dot x+2,y+6:dot x+3,y+6:dot x+4,y+6:dot x+5,y+6:dot x+6,y+6:dot x+7,y+6:dot x+8,y+6:dot x+9,y+6:dot x+10,y+6:dot x+11,y+6:dot x+12,y+6:dot x+13,y+6:dot x+14,y+6:dot x+15,y+6:dot x+16,y+6:dot x+17,y+6:dot x+18,y+6:dot x+19,y+6:dot x+20,y+6:dot x+21,y+6:dot x+22,y+6:dot x+23,y+6:dot x+24,y+6
   dot x+1,y+7:dot x+2,y+7:dot x+3,y+7:dot x+4,y+7:dot x+5,y+7:dot x+6,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+19,y+7:dot x+20,y+7:dot x+21,y+7:dot x+22,y+7:dot x+23,y+7:dot x+24,y+7
   dot x+1,y+8:dot x+2,y+8:dot x+3,y+8:dot x+4,y+8:dot x+5,y+8:dot x+6,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+19,y+8:dot x+20,y+8:dot x+21,y+8:dot x+22,y+8:dot x+23,y+8:dot x+24,y+8
   dot x+1,y+9:dot x+2,y+9:dot x+3,y+9:dot x+4,y+9:dot x+5,y+9:dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9:dot x+20,y+9:dot x+21,y+9:dot x+22,y+9:dot x+23,y+9:dot x+24,y+9
   dot x+2,y+10:dot x+3,y+10:dot x+4,y+10:dot x+5,y+10:dot x+6,y+10:dot x+7,y+10:dot x+8,y+10:dot x+9,y+10:dot x+10,y+10:dot x+11,y+10:dot x+12,y+10:dot x+13,y+10:dot x+14,y+10:dot x+15,y+10:dot x+16,y+10:dot x+17,y+10:dot x+18,y+10:dot x+19,y+10:dot x+20,y+10:dot x+21,y+10:dot x+22,y+10:dot x+23,y+10
   dot x+5,y+11:dot x+6,y+11:dot x+7,y+11:dot x+8,y+11:dot x+9,y+11:dot x+10,y+11:dot x+15,y+11:dot x+16,y+11:dot x+17,y+11:dot x+18,y+11:dot x+19,y+11:dot x+20,y+11
   dot x+5,y+12:dot x+6,y+12:dot x+7,y+12:dot x+8,y+12:dot x+9,y+12:dot x+10,y+12:dot x+15,y+12:dot x+16,y+12:dot x+17,y+12:dot x+18,y+12:dot x+19,y+12:dot x+20,y+12
   dot x+3,y+13:dot x+4,y+13:dot x+5,y+13:dot x+6,y+13:dot x+10,y+13:dot x+11,y+13:dot x+12,y+13:dot x+13,y+13:dot x+14,y+13:dot x+15,y+13:dot x+19,y+13:dot x+20,y+13:dot x+21,y+13:dot x+22,y+13
   dot x+3,y+14:dot x+4,y+14:dot x+5,y+14:dot x+6,y+14:dot x+7,y+14:dot x+11,y+14:dot x+12,y+14:dot x+13,y+14:dot x+14,y+14:dot x+18,y+14:dot x+19,y+14:dot x+20,y+14:dot x+21,y+14:dot x+22,y+14
   dot x+4,y+15:dot x+5,y+15:dot x+6,y+15:dot x+7,y+15:dot x+8,y+15:dot x+17,y+15:dot x+18,y+15:dot x+19,y+15:dot x+20,y+15:dot x+21,y+15
   dot x+5,y+16:dot x+6,y+16:dot x+7,y+16:dot x+8,y+16:dot x+17,y+16:dot x+18,y+16:dot x+19,y+16:dot x+20,y+16
image_width=24
image_height=16
endif
if alien=3 and frame=1
   dot x+9,y+1:dot x+10,y+1:dot x+11,y+1:dot x+12,y+1:dot x+13,y+1:dot x+14,y+1:dot x+15,y+1:dot x+16,y+1
   dot x+7,y+2:dot x+8,y+2:dot x+9,y+2:dot x+10,y+2:dot x+11,y+2:dot x+12,y+2:dot x+13,y+2:dot x+14,y+2:dot x+15,y+2:dot x+16,y+2:dot x+17,y+2:dot x+18,y+2
   dot x+3,y+3:dot x+4,y+3:dot x+5,y+3:dot x+6,y+3:dot x+7,y+3:dot x+8,y+3:dot x+9,y+3:dot x+10,y+3:dot x+11,y+3:dot x+12,y+3:dot x+13,y+3:dot x+14,y+3:dot x+15,y+3:dot x+16,y+3:dot x+17,y+3:dot x+18,y+3:dot x+19,y+3:dot x+20,y+3:dot x+21,y+3:dot x+22,y+3
   dot x+2,y+4:dot x+3,y+4:dot x+4,y+4:dot x+5,y+4:dot x+6,y+4:dot x+7,y+4:dot x+8,y+4:dot x+9,y+4:dot x+10,y+4:dot x+11,y+4:dot x+12,y+4:dot x+13,y+4:dot x+14,y+4:dot x+15,y+4:dot x+16,y+4:dot x+17,y+4:dot x+18,y+4:dot x+19,y+4:dot x+20,y+4:dot x+21,y+4:dot x+22,y+4:dot x+23,y+4
   dot x+1,y+5:dot x+2,y+5:dot x+3,y+5:dot x+4,y+5:dot x+5,y+5:dot x+6,y+5:dot x+7,y+5:dot x+8,y+5:dot x+9,y+5:dot x+10,y+5:dot x+11,y+5:dot x+12,y+5:dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5:dot x+19,y+5:dot x+20,y+5:dot x+21,y+5:dot x+22,y+5:dot x+23,y+5:dot x+24,y+5
   dot x+1,y+6:dot x+2,y+6:dot x+3,y+6:dot x+4,y+6:dot x+5,y+6:dot x+6,y+6:dot x+7,y+6:dot x+8,y+6:dot x+9,y+6:dot x+10,y+6:dot x+11,y+6:dot x+12,y+6:dot x+13,y+6:dot x+14,y+6:dot x+15,y+6:dot x+16,y+6:dot x+17,y+6:dot x+18,y+6:dot x+19,y+6:dot x+20,y+6:dot x+21,y+6:dot x+22,y+6:dot x+23,y+6:dot x+24,y+6
   dot x+1,y+7:dot x+2,y+7:dot x+3,y+7:dot x+4,y+7:dot x+5,y+7:dot x+6,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+19,y+7:dot x+20,y+7:dot x+21,y+7:dot x+22,y+7:dot x+23,y+7:dot x+24,y+7
   dot x+1,y+8:dot x+2,y+8:dot x+3,y+8:dot x+4,y+8:dot x+5,y+8:dot x+6,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+19,y+8:dot x+20,y+8:dot x+21,y+8:dot x+22,y+8:dot x+23,y+8:dot x+24,y+8
   dot x+1,y+9:dot x+2,y+9:dot x+3,y+9:dot x+4,y+9:dot x+5,y+9:dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9:dot x+20,y+9:dot x+21,y+9:dot x+22,y+9:dot x+23,y+9:dot x+24,y+9
   dot x+2,y+10:dot x+3,y+10:dot x+4,y+10:dot x+5,y+10:dot x+6,y+10:dot x+7,y+10:dot x+8,y+10:dot x+9,y+10:dot x+10,y+10:dot x+11,y+10:dot x+12,y+10:dot x+13,y+10:dot x+14,y+10:dot x+15,y+10:dot x+16,y+10:dot x+17,y+10:dot x+18,y+10:dot x+19,y+10:dot x+20,y+10:dot x+21,y+10:dot x+22,y+10:dot x+23,y+10
   dot x+7,y+11:dot x+8,y+11:dot x+9,y+11:dot x+10,y+11:dot x+15,y+11:dot x+16,y+11:dot x+17,y+11:dot x+18,y+11
   dot x+7,y+12:dot x+8,y+12:dot x+9,y+12:dot x+10,y+12:dot x+11,y+12:dot x+14,y+12:dot x+15,y+12:dot x+16,y+12:dot x+17,y+12:dot x+18,y+12
   dot x+5,y+13:dot x+6,y+13:dot x+7,y+13:dot x+8,y+13:dot x+10,y+13:dot x+11,y+13:dot x+12,y+13:dot x+13,y+13:dot x+14,y+13:dot x+15,y+13:dot x+17,y+13:dot x+18,y+13:dot x+19,y+13:dot x+20,y+13
   dot x+4,y+14:dot x+5,y+14:dot x+6,y+14:dot x+7,y+14:dot x+8,y+14:dot x+11,y+14:dot x+12,y+14:dot x+13,y+14:dot x+14,y+14:dot x+17,y+14:dot x+18,y+14:dot x+19,y+14:dot x+20,y+14:dot x+21,y+14
   dot x+1,y+15:dot x+2,y+15:dot x+3,y+15:dot x+4,y+15:dot x+5,y+15:dot x+20,y+15:dot x+21,y+15:dot x+22,y+15:dot x+23,y+15:dot x+24,y+15
   dot x+1,y+16:dot x+2,y+16:dot x+3,y+16:dot x+4,y+16:dot x+21,y+16:dot x+22,y+16:dot x+23,y+16:dot x+24,y+16
image_width=24
image_height=16
endif
endfunction
function draw_gun(x,y)
   dot x+15,y+1:dot x+16,y+1
   dot x+15,y+2:dot x+16,y+2
   dot x+15,y+3:dot x+16,y+3
   dot x+14,y+4:dot x+15,y+4:dot x+16,y+4:dot x+17,y+4
   dot x+13,y+5:dot x+14,y+5:dot x+15,y+5:dot x+16,y+5:dot x+17,y+5:dot x+18,y+5
   dot x+13,y+6:dot x+14,y+6:dot x+15,y+6:dot x+16,y+6:dot x+17,y+6:dot x+18,y+6
   dot x+3,y+7:dot x+4,y+7:dot x+5,y+7:dot x+6,y+7:dot x+7,y+7:dot x+8,y+7:dot x+9,y+7:dot x+10,y+7:dot x+11,y+7:dot x+12,y+7:dot x+13,y+7:dot x+14,y+7:dot x+15,y+7:dot x+16,y+7:dot x+17,y+7:dot x+18,y+7:dot x+19,y+7:dot x+20,y+7:dot x+21,y+7:dot x+22,y+7:dot x+23,y+7:dot x+24,y+7:dot x+25,y+7:dot x+26,y+7:dot x+27,y+7:dot x+28,y+7
   dot x+2,y+8:dot x+3,y+8:dot x+4,y+8:dot x+5,y+8:dot x+6,y+8:dot x+7,y+8:dot x+8,y+8:dot x+9,y+8:dot x+10,y+8:dot x+11,y+8:dot x+12,y+8:dot x+13,y+8:dot x+14,y+8:dot x+15,y+8:dot x+16,y+8:dot x+17,y+8:dot x+18,y+8:dot x+19,y+8:dot x+20,y+8:dot x+21,y+8:dot x+22,y+8:dot x+23,y+8:dot x+24,y+8:dot x+25,y+8:dot x+26,y+8:dot x+27,y+8:dot x+28,y+8:dot x+29,y+8
   dot x+1,y+9:dot x+2,y+9:dot x+3,y+9:dot x+4,y+9:dot x+5,y+9:dot x+6,y+9:dot x+7,y+9:dot x+8,y+9:dot x+9,y+9:dot x+10,y+9:dot x+11,y+9:dot x+12,y+9:dot x+13,y+9:dot x+14,y+9:dot x+15,y+9:dot x+16,y+9:dot x+17,y+9:dot x+18,y+9:dot x+19,y+9:dot x+20,y+9:dot x+21,y+9:dot x+22,y+9:dot x+23,y+9:dot x+24,y+9:dot x+25,y+9:dot x+26,y+9:dot x+27,y+9:dot x+28,y+9:dot x+29,y+9:dot x+30,y+9
   dot x+1,y+10:dot x+2,y+10:dot x+3,y+10:dot x+4,y+10:dot x+5,y+10:dot x+6,y+10:dot x+7,y+10:dot x+8,y+10:dot x+9,y+10:dot x+10,y+10:dot x+11,y+10:dot x+12,y+10:dot x+13,y+10:dot x+14,y+10:dot x+15,y+10:dot x+16,y+10:dot x+17,y+10:dot x+18,y+10:dot x+19,y+10:dot x+20,y+10:dot x+21,y+10:dot x+22,y+10:dot x+23,y+10:dot x+24,y+10:dot x+25,y+10:dot x+26,y+10:dot x+27,y+10:dot x+28,y+10:dot x+29,y+10:dot x+30,y+10
   dot x+1,y+11:dot x+2,y+11:dot x+3,y+11:dot x+4,y+11:dot x+5,y+11:dot x+6,y+11:dot x+7,y+11:dot x+8,y+11:dot x+9,y+11:dot x+10,y+11:dot x+11,y+11:dot x+12,y+11:dot x+13,y+11:dot x+14,y+11:dot x+15,y+11:dot x+16,y+11:dot x+17,y+11:dot x+18,y+11:dot x+19,y+11:dot x+20,y+11:dot x+21,y+11:dot x+22,y+11:dot x+23,y+11:dot x+24,y+11:dot x+25,y+11:dot x+26,y+11:dot x+27,y+11:dot x+28,y+11:dot x+29,y+11:dot x+30,y+11
   dot x+1,y+12:dot x+2,y+12:dot x+3,y+12:dot x+4,y+12:dot x+5,y+12:dot x+6,y+12:dot x+7,y+12:dot x+8,y+12:dot x+9,y+12:dot x+10,y+12:dot x+11,y+12:dot x+12,y+12:dot x+13,y+12:dot x+14,y+12:dot x+15,y+12:dot x+16,y+12:dot x+17,y+12:dot x+18,y+12:dot x+19,y+12:dot x+20,y+12:dot x+21,y+12:dot x+22,y+12:dot x+23,y+12:dot x+24,y+12:dot x+25,y+12:dot x+26,y+12:dot x+27,y+12:dot x+28,y+12:dot x+29,y+12:dot x+30,y+12
   dot x+1,y+13:dot x+2,y+13:dot x+3,y+13:dot x+4,y+13:dot x+5,y+13:dot x+6,y+13:dot x+7,y+13:dot x+8,y+13:dot x+9,y+13:dot x+10,y+13:dot x+11,y+13:dot x+12,y+13:dot x+13,y+13:dot x+14,y+13:dot x+15,y+13:dot x+16,y+13:dot x+17,y+13:dot x+18,y+13:dot x+19,y+13:dot x+20,y+13:dot x+21,y+13:dot x+22,y+13:dot x+23,y+13:dot x+24,y+13:dot x+25,y+13:dot x+26,y+13:dot x+27,y+13:dot x+28,y+13:dot x+29,y+13:dot x+30,y+13
   dot x+1,y+14:dot x+2,y+14:dot x+3,y+14:dot x+4,y+14:dot x+5,y+14:dot x+6,y+14:dot x+7,y+14:dot x+8,y+14:dot x+9,y+14:dot x+10,y+14:dot x+11,y+14:dot x+12,y+14:dot x+13,y+14:dot x+14,y+14:dot x+15,y+14:dot x+16,y+14:dot x+17,y+14:dot x+18,y+14:dot x+19,y+14:dot x+20,y+14:dot x+21,y+14:dot x+22,y+14:dot x+23,y+14:dot x+24,y+14:dot x+25,y+14:dot x+26,y+14:dot x+27,y+14:dot x+28,y+14:dot x+29,y+14:dot x+30,y+14
   dot x+1,y+15:dot x+2,y+15:dot x+3,y+15:dot x+4,y+15:dot x+5,y+15:dot x+6,y+15:dot x+7,y+15:dot x+8,y+15:dot x+9,y+15:dot x+10,y+15:dot x+11,y+15:dot x+12,y+15:dot x+13,y+15:dot x+14,y+15:dot x+15,y+15:dot x+16,y+15:dot x+17,y+15:dot x+18,y+15:dot x+19,y+15:dot x+20,y+15:dot x+21,y+15:dot x+22,y+15:dot x+23,y+15:dot x+24,y+15:dot x+25,y+15:dot x+26,y+15:dot x+27,y+15:dot x+28,y+15:dot x+29,y+15:dot x+30,y+15
   dot x+1,y+16:dot x+2,y+16:dot x+3,y+16:dot x+4,y+16:dot x+5,y+16:dot x+6,y+16:dot x+7,y+16:dot x+8,y+16:dot x+9,y+16:dot x+10,y+16:dot x+11,y+16:dot x+12,y+16:dot x+13,y+16:dot x+14,y+16:dot x+15,y+16:dot x+16,y+16:dot x+17,y+16:dot x+18,y+16:dot x+19,y+16:dot x+20,y+16:dot x+21,y+16:dot x+22,y+16:dot x+23,y+16:dot x+24,y+16:dot x+25,y+16:dot x+26,y+16:dot x+27,y+16:dot x+28,y+16:dot x+29,y+16:dot x+30,y+16
image_width=30
image_height=16
endfunction