i've done this but there are some collision problems because if the ball moves too fast it can miss the collision range and if you set the range too big you get the ball rebounding inside the bat, collision and controls for my gam (basically all of it except the original setup at the start and the loop:
function ballmovement(ball, playerobject,)
rem move the ball in the direction it's facing
move object ball, 0.25
rem get player bat then ball positions
x#=object position x(playerobject)
y#=object position y(playerobject)
z#=object position z(playerobject)
x2#=object position x(ball)
y2#=object position y(ball)
z2#=object position z(ball)
if ball at right side boundary of play then bounce
if x2#>30 then yrotate object ball, (360-object angle y(ball)) : play sound 1
if ball at left side boundary of play then bounce
if x2#<-10 then yrotate object ball,(360-object angle y(ball)) : play sound 1
if ball at far side boundary of play then bounce
if z2#>50 then yrotate object ball,(180-object angle y(ball)) : play sound 1
rem bat collisions and bounce
rem front of bat
if x2#>x#-3.5 and x2#<x#+3.5 and z2#>z#+2 and z2#<z#+2.2 then yrotate object ball, (180-object angle y(ball)) : play sound 1
rem left side of bat
if z2#>z#-1.9 and z2#<z#+1.9 and x2#<x#-3 and x2#>x#-3.5 then yrotate object ball, (360-object angle y(ball)) : play sound 1
rem right side of bat
if z2#>z#-1.9 and z2#<z#+1.9 and x2#>x#+3 and x2#<x#+3.5 then yrotate object ball, (360-object angle y(ball)) : play sound 1
rem if OBJECT COLLISION(ball, 0)=100
rem detect if ball is behind bat and take away a life, then reset
rem bat and ball positions and start again
if z2#<-1
life#=life#-1
wait 1000
position object ball, 10,2,3
position object playerobject, 10,2,0
yrotate object ball, rnd(60)
endif
rem if all lives are gone then quit and display score in a message box
if life#<0
score$=str$(score#)
exit prompt "game over score:"+ score$, "game over"
end
endif
set cursor 0,0
rem print lives remaining
print "lives remaining:", life#
endfunction
function playermovement(playerobject,ball)
rem get bat positions
x#=object position x(playerobject)
y#=object position y(playerobject)
x#=object position x(playerobject)
rem check to see if bat is at the boundaries and set variable accordingly
if x#<30 then rightcollide=0
if x#>30 then rightcollide=1
if x#>-10 then leftcollide=0
if x#<-10 then leftcollide=1
rem if collision with left is not 1 and left key if presed then bat moves left
if leftkey()=1 and leftcollide=0 then move object left playerobject,0.5
trm if collision with right is not 1 and left key if presed then bat moves right
if rightkey()=1 and rightcollide=0 then move object right playerobject,0.5
endfunction
function collisioncubes(ball)
rem get ball position
x2#=object position x(ball)
y2#=object position y(ball)
z2#=object position z(ball)
check for all 36 cubes
for q=1 to 6
for i=1 to 6
u=10*q
h=u+i
obj=h
if object exist(obj)=1
rem get cube position
x3#=object position x(obj)
y3#=object position y(obj)
z3#=object position z(obj)
rem check back of cube collision then if it is colliding with the
rem ball then delete the object if the object exists and rebound ball
rem and add to score (also play sound, all collisions play the sound)
if x2#>x3#-2 and x2#<x3#+2 and z2#>z3#+1.6 and z2#<z3#+2.3 and object exist(obj)=1
yrotate object ball, (180-object angle y(ball))
delete object obj
score#=score#+1
balls=balls-1
play sound 1
endif
rem check front of cube collision then if it is colliding with the
rem ball then delete the object if the object exists and rebound ball
rem and add to score (also play sound, all collisions play the sound)
if x2#>x3#-2 and x2#<x3#+2 and z2#<z3#-1.6 and z2#>z3#-2.3 and object exist(obj)=1
yrotate object ball, (180-object angle y(ball))
delete object obj
score#=score#+1
balls=balls-1
play sound 1
endif
rem check left of cube collision then if it is colliding with the
rem ball then delete the object if the object exists and rebound ball
rem and add to score (also play sound, all collisions play the sound)
if z2#>z3#-2 and z2#<z3#+2 and x2#<x3#-1.6 and x2#>x3#-2.3 and object exist(obj)=1
yrotate object ball, (360-object angle y(ball))
delete object obj
score#=score#+1
balls=balls-1
play sound 1
endif
rem check right of cube collision then if it is colliding with the
rem ball then delete the object if the object exists and rebound ball
rem and add to score (also play sound, all collisions play the sound)
if z2#>z3#-2 and z2#<z3#+2 and x2#>x3#+1.6 and x2#<x3#+2.3 and object exist(obj)=1
yrotate object ball, (360-object angle y(ball))
delete object obj
score#=score#+1
balls=balls-1
play sound 1
endif
endif
next i
next q
rem print the score
set cursor 0,20
print "score:", score#
rem print the number of remaining cubes
set cursor 0,40
print "cubes remaining:",balls
if balls=0
if there are no cubes left then increase lives by one, make the
rem cubes again and increase speed
rem (level is a wait value in the main loop)
wait 500
life#=life#+1
makecubes()
if level>0
level=level-5
endif
endif
endfunction
function makecubes()
for q=1 to 6
for i=1 to 6
u=10*q
h=u+i
obj=h
make object cube obj,2
color object obj, rgb(0,255,0)
position object obj,6*i-10,2,6*q+10
next i
next q
rem reset the number of cubes left
balls=36
rem set/reset the camera position (this function is called at the
rem very start as well as when all the cubes are deleted)
position camera 10, 25, -10
xrotate camera 45
endfunction
i hope you can understand it and that it helps
if you want more explination then email me. edit:i've added some rems(the balls variable is actually the number of cubes left. sorry it's a bit messy)
http://www.larinar.tk
AMD athlon thoroughbred 2200, 512Mb ram, 40Gb HD, ati saphire radeon 9600 atlantis w/128mb ddr ram, good creative-labs soundcard, cd-rw + dvd drives.