you need to reposition your ball after changing the ballX and ballY variables.
You can do this most easily be using a few different variables, such as:
(pseudocode-ish)
int ballX; //store the current position
int ballY; //store the current position
int ballMove; //your random value
int ball = 1; // create an ID number for your ball object
int radius = 10; //set the size of the ball here
//Create a ball
dbMakeObjectSphere(ball,radius);
//Initialize your ball's location, X, Y Z
ballX = Some # (whatever it will be);
ballY = Some # (whatever it will be);
ballZ = Some # (whatever it will be);
//Position the ball at its initial location
dbPositionObject(ballObject,ballX,ballY,ballZ);
while (gameRunning)
{
ballMove = dbRND(4);
switch (ballMove)
{
case 0:
ballY--;
break;
case 1:
ballY++;
break;
case 2:
ballX--;
break;
case 3:
ballX++;
break;
} //end the Switch
//Reposition the ball at the new coordinate
dbPositionObject(ball,ballX,ballY,ballZ );
dbSync(); //redraw the screen
} //loop as often as the program runs
} //end the program
Is this helpful?