I am currently trying to move an object (circle ball) around the canvas in a random direction.
I have already written the code for the wall collisions so the ball bounces back into canvas when the ball hits any of the canvas sides.
The canvas size is 600 x 500
in order to move the object around the canvas I have used;
xPosition += ySpeed; yPosition += ySpeed;
From the code above, the ball moves from one end to the other end of the canvas in the same angle and direction, then bounces back at a different angle.
How can I go about doing this, if I wanted my object to move in the same speed but in a random direction around the canvas.
Any help is appreciated, thanks!