do you wanta pong/breakout effect?
If so just reverse the relevent velocity when ball hits boundry. ie reverse x velocity when ball hits left wall or right wall and reverse y velocity when ball hits top wall or bat. Thats the basic physics you need to add a bit for effects of ball hitting a moving bat but that shouldn't be 2 hard.
Anyway I diddled with your code a bit:
rem setup
sync on
sync rate 35
hide mouse
rem placing the camera
make camera 1
position camera 1,0,0,0
color backdrop 1,RGB(0,0,0)
rem make the player
make object box 1,10,2,2
color object 1,RGB(255,255,0)
position object 1,0,-25,50
rem make ball
make object sphere 2,2
color object 2,RGB(0,255,0)
position object 2,0,-23,50
rem make the player move
do
if leftkey()=1 and object position x(1)>-30
move object left 1,1.5
if xvelocity#=0 then move object left 2,1.5
endif
if rightkey()=1 and object position x(1)<30
move object right 1,1.5
if xvelocity#=0 then move object right 2,1.5
endif
if keystate(57) and xvelocity#=0
xvelocity#=0.5
yvelocity#=0.5
endif
position object 2,object position x(2)+xvelocity#,object position y(2)+yvelocity#,object position z(2)
if object position x(2)<-35 or object position x(2)>35 then xvelocity#=0-xvelocity#
if object position y(2)>28 or object collision (1,2) then yvelocity#=0-yvelocity#
if object position y(2)<-30
xvelocity#=0
yvelocity#=0
position object 1,0,-25,50
position object 2,0,-23,50
endif
sync
loop
hope this helps