I think, with this code, it can't work. You never change ball_speed, so the ball can never bounce from the wall.

You don't need two c_move's, because you can put both directions (x/y) in one c_move-vector.

If you use the same value for x/y, the ball will allways fly in a 45° angle. You could use differnet vars for x and y speed. Also, you could use collision-detection and the BOUNCE-result of a collision to set the new direction of the ball. In your code, you don't change any speed, when collision with the wall.

Your brackets are not correct. In the ball-action the checks for the left and right wall are only done, when the ball hits the upper wall. I've formated your code to make it clear
Code:
action ball()
{
	var ball_speed =30;
	var top_border= 100;
	var Rside_border= 400;
	var Lside_border= -200;
	while(1)
	{
		c_move (my, vector(0, 0, ball_speed * time_step), nullvector, GLIDE);
		c_move (my, vector(0, -ball_speed * time_step, 0), nullvector, GLIDE);
		
		
		if (my.z>=top_border)
		{
			my.z-=3 -random(3); 
			my.y+=3 +random(3); 
		
			if(my.y<=Lside_border)
			{
				my.y-=ball_speed*time_step - random(3);
				my.z+=ball_speed*time_step + random(3);
			}
			if (my.y>=Rside_border)
			{
				my.y+=ball_speed*time_step -random(3);
				my.z+=ball_speed*time_step + random(3);
			}
		}
		wait(1);
	}
}



Last edited by bodden; 09/24/10 07:10.