hide mouse
set display mode 1024,768,32
sync on
 
 
type graphic
   xpos as integer
   ypos as integer
   state as integer
   graphic_type as string
   rotation as integer
 
endtype
 
Global RIGHT_PADDLE as string ="right paddle"
GLOBAL LEFT_PADDLE as string="left paddle"
global right_pressed as integer
global left_pressed as integer
 
 
 
dim paddles(2) as graphic
paddles(1).xpos=384:paddles(1).ypos=650:paddles(1).graphic_type=RIGHT_PADDLE
paddles(2).xpos=628:paddles(2).ypos=650:paddles(2).graphic_type=LEFT_PADDLE
 
do
cls
 
controls()
update_doodad_state()
draw_doodads()
 
sync
loop
 
 
function draw_doodads()
 ink rgb(0,0,255),0
 line 368,650,275,650:line 275,650,275,50:line 646,650,739,650:line 739,650,739,50:line 739,50,275,50
 ink rgb(255,255,0),0
 circle paddles(1).xpos,paddles(1).ypos,15
 ink 0,0:box paddles(1).xpos,paddles(1).ypos-15,paddles(1).xpos+16,paddles(1).ypos+16:ink rgb(255,255,0),0
 line paddles(1).xpos,paddles(1).ypos-15,paddles(1).xpos+80,paddles(1).ypos+25+paddles(1).rotation
 line paddles(1).xpos,paddles(1).ypos+15,paddles(1).xpos+80,paddles(1).ypos+25+paddles(1).rotation
 circle paddles(2).xpos,paddles(2).ypos,15
 ink 0,0:box paddles(2).xpos-16,paddles(2).ypos-15,paddles(2).xpos,paddles(2).ypos+16:ink rgb(255,255,0),0
 line paddles(2).xpos,paddles(2).ypos-15,paddles(2).xpos-80,paddles(2).ypos+25+paddles(2).rotation
 line paddles(2).xpos,paddles(2).ypos+15,paddles(2).xpos-80,paddles(2).ypos+25+paddles(2).rotation
endfunction
 
function controls()
   k$=inkey$()
   if k$="" then right_pressed=0:left_pressed=0
   if k$="z" and paddles(1).state=0 and right_pressed=0
      paddles(1).state=1
      right_pressed=1
   endif
   if k$="/" and paddles(2).state=0 and left_pressed=0
      paddles(2).state=1
      left_pressed=1
   endif
endfunction
 
function update_doodad_state()
   if paddles(1).state=1
      if paddles(1).rotation>-50
         dec paddles(1).rotation,2
      else
         paddles(1).state=2
      endif
   endif
   if paddles(1).state=2 and right_pressed=0
      if paddles(1).rotation<0
         inc paddles(1).rotation,2
      else
         paddles(1).state=0
      endif
   endif
 
   if paddles(2).state=1
      if paddles(2).rotation>-50
         dec paddles(2).rotation,2
      else
         paddles(2).state=2
      endif
   endif
   if paddles(2).state=2 and left_pressed=0
      if paddles(2).rotation<0
         inc paddles(2).rotation,2
      else
         paddles(2).state=0
      endif
   endif
endfunction