sync on
set display mode 1024,768,32
 
global centerx=512
global centery=384
global player_position=1
global can_move=timer()
 
type bullet
   xpos as float
   ypos as float
   xstepvalue as float
   ystepvalue as float
   x_des as float
   y_des as float
   spritenumber as integer
   endstep as integer
endtype
 
dim shot(-1) as bullet
 
create bitmap 1,10,10
ink rgb(255,0,0),0
line 1,1,9,9:line 9,0,0,9:line 0,5,9,5:line 5,0,5,9
get image 1,0,0,9,9,1
delete bitmap 1
 
 
dim shapepoint(33,2)
for a = 1 to 32
   for b = 1 to 2
      read shapepoint(a,b)
   next b
next a
 
do
   cls
   for a = 1 to 32
 
 
      nextpoint=a+1
      if nextpoint>32 then nextpoint=1
      ink rgb(255,255,0),0
      line centerx+shapepoint(a,1),centery+shapepoint(a,2),centerx+(shapepoint(a,1)/16),centery+(shapepoint(a,2)/16)
      ink rgb(0,0,255),0
      line centerx+shapepoint(a,1),centery+shapepoint(a,2),centerx+shapepoint(nextpoint,1),centery+shapepoint(nextpoint,2)
      line centerx+(shapepoint(a,1)/16),centery+(shapepoint(a,2)/16),centerx+(shapepoint(nextpoint,1)/16),centery+(shapepoint(nextpoint,2)/16)
 
 
   next a
   if can_move<=timer()
      if leftkey()=1
         dec player_position
         can_move=timer()+100
 
      endif
      if rightkey()=1
         inc player_position
         can_move=timer()+100
 
      endif
      if spacekey()=1
         add_bullet()
         can_move=timer()+100
 
      endif
   endif
 
   if player_position<1 then player_position=32
   if player_position>32 then player_position=1
   if array count(shot())>=0 then move_bullets()
 
   ink rgb(255,0,255),0
   endpoint=player_position+1
   if endpoint>32 then endpoint=1
   box (centerx+shapepoint(player_position,1)+centerx+shapepoint(endpoint,1))/2-5,(centery+shapepoint(player_position,2)+centery+shapepoint(endpoint,2))/2-5,(centerx+shapepoint(player_position,1)+centerx+shapepoint(endpoint,1))/2+5,(centery+shapepoint(player_position,2)+centery+shapepoint(endpoint,2))/2+5
   sync
loop
 
 
` Square level
data -200,-200,-150,-200,-100,-200,-50,-200,0,-200,50,-200,100,-200,150,-200
data 200,-200,200,-150,200,-100,200,-50,200,0,200,50,200,100,200,150
data 200,200,150,200,100,200,50,200,0,200,-50,200,-100,200,-150,200
data -200,200,-200,150,-200,100,-200,50,-200,0,-200,-50,-200,-100,-200,-150
 
function add_bullet()
   array insert at top shot()
   endpoint=player_position+1
   if endpoint>32 then endpoint=1
   shot(0).xpos=(centerx+shapepoint(player_position,1)+centerx+shapepoint(endpoint,1))/2
   shot(0).ypos=(centery+shapepoint(player_position,2)+centery+shapepoint(endpoint,2))/2
   shot(0).x_des=(centerx+(shapepoint(player_position,1)/16)+centerx+(shapepoint(endpoint,1)/16))/2
   shot(0).y_des=(centery+(shapepoint(player_position,2)/16)+centery+(shapepoint(endpoint,2)/16))/2
   shot(0).xstepvalue=(shot(0).x_des-shot(0).xpos)/20
   shot(0).ystepvalue=(shot(0).y_des-shot(0).ypos)/20
   shot(0).spritenumber=free_sprite()
   shot(0).endstep=20
   sprite shot(0).spritenumber,shot(0).xpos,shot(0).ypos,1
endfunction
 
function move_bullets()
   for a = array count(shot()) to 0 step -1
   shot(a).xpos=shot(a).xpos+shot(a).xstepvalue
   shot(a).ypos=shot(a).ypos+shot(a).ystepvalue
   dec shot(a).endstep
   scale sprite shot(a).spritenumber,40+shot(a).endstep*3
   sprite shot(a).spritenumber,shot(a).xpos,shot(a).ypos,1
   if shot(a).endstep<=0
      delete sprite shot(a).spritenumber
      array delete element shot(),a
   endif
   next a
endfunction
 
 
function free_sprite()
   x=0
   repeat
      inc x
   until sprite exist(x)=0
endfunction x