Random movement and collision detection

I am trying to make a ball randomly move around the screen and bounce off the of it.

I have been looking for some tutorial or something worthwile to read but I am struggling. Would anyone be able to help me out or link me to some documentation on random movement of an object and collision detection. for now I will keep looking.
Thank you :)
Use gotoxy(int x,inty) statement to print any thing anywhere on the screen.
You know the bounds of the ball, so use that with the size of the screen.

So, if your pivot of the ball/image is at the top left, you would check if the position of the ball + width was greater than the screen width( If you are moving right ).

1
2
3
4
if( ( ball.x + ball.width ) > screenWidth )
{
    // Change direction or what ever here.
}
Last edited on
Thank you Lynx that is perfect. I will have a go and post my code
Topic archived. No new replies allowed.