Hi, I'm assuming that when you say "moving the sphere at random" you mean moving it in a random direction. Anyway I modified your code snippet and I hope this is what you are after.
Press the spacebar to reset the ball
Rem ***** Main Source File *****
sync on : sync rate 60
randomize timer()
ball_angle as float
ballx as float = 100.00
bally as float = -8.00
ballz as float = 1500.00
ballxspeed as float
ballyspeed as float
start_ball as boolean = 1
set display mode 800,800,32
make object box 1,10,30,2
make object box 2,10,30,2
make object sphere 3,4
position object 1,-1100,-8,1500
position object 2,1100,-8,1500
position object 3,100,-8,1500
scale object 1,600,700,50
scale object 2,600,700,50
scale object 3,1000,1000,50
do
if downkey() = 1 then move object down 1,1
if upkey() =1 then move object up 1,1
if keystate(17) = 1 then move object up 2,1
if keystate(31) = 1 then move object down 2,1
// start the ball
if start_ball = 1
// give the ball a random direction
ball_angle = wrapvalue(rnd(360))
start_ball = 0
endif
// base the x and y speeds on the direction
ballxspeed = sin(ball_angle)*5 // change the '5' to speed up or slow down
ballyspeed = cos(ball_angle)*5
// move the ball
inc ballx, ballxspeed
inc bally, ballyspeed
// reset the ball
if spacekey()=1 and start_ball = 0
ballx = 100
bally = -8
ballz = 1500
start_ball = 1
endif
// position the ball
position object 3, ballx, bally, ballz
sync
loop
Hope this helps
A clever person solves a problem, a wise person avoids it - Albert Einstein