REM Project: Pinball
REM Created: 7/25/2006 8:51:31 PM
REM
REM ***** Main Source File *****
REM
make camera 1
move camera 1,-30
make object box 1,0.5,30,0.5
make object box 2,0.5,30,0.5
make object box 3,20,0.5,0.5
make object box 4,20,0.5,0.5
position object 1,-9.9,0,0
position object 2,10,0,0
position object 3,0,14.75,0
position object 4,0,-14.75,0
make object box 5,6,1.5,0.5
make object box 6,6,1.5,0.5
zrotate object 5,-45
zrotate object 6,45
position object 5,-4.5,-7,0
position object 6,4.6,-7,0
make object sphere 10,1
position object 10,3,0,0
set object collision to polygons 5
set object collision to polygons 6
zrotate object 10,180
 
do
if leftkey()=1 and leftflip=0 then leftflip=4
if rightkey()=1 and rightflip=0 then rightflip=4
if leftflip>2
leftflip=leftflip-1
flipper(1,5,1)
endif
if leftflip>0 and leftflip<3
leftflip=leftflip-1
flipper(0,5,1)
endif
if rightflip>2
rightflip=rightflip-1
flipper(1,6,0)
endif
if rightflip>0 and rightflip<3
rightflip=rightflip-1
flipper(0,6,0)
endif
g#=g#+0.02
if l=0 then move object up 10,g#
collision()
wait 25
loop
 
function flipper(up,object,left)
if left=1
   move object left object,3
   if up=1
   global leftup=1
      roll object left object,24
   else
   global leftup=0
      roll object right object,24
   endif
   move object right object,3
else
   move object right object,3
   if up=1
      global rightup=1
      roll object right object,24
   else
      global rightup=0
      roll object left object,24
   endif
   move object left object,3
endif
endfunction
 
function collision()
 
   x=object position x(10)
   y=object position y(10)
   angz=object angle z(10)
   if object collision(6,10)>0
      g#=0
      move object down 10,0.2
      testagain:
      t=t+1
      if t=360
      zrotate object 10,angz
      t=0
      move object down 10,3
      endif
      roll object right 10,1
      move object up 10,0.5
      if object collision(6,10)>0
         move object up 10,-0.5
         goto testagain
      endif
      move object up 10,-0.5
    angz2=object angle z(10)-angz
    if rightup=1
    angz2=angz2*2
    v=5
    l=50
    endif
    zrotate object 10,angz
    move object up 10,0.2
    roll object left 10,angz2
   endif
endfunction