How to make balls bounce off the edges in Greenfoot

458 Views Asked by At

I am learning programming on Greenfoot. I'm creating a scenario that has 5 balls which will follow these properties:

  1. The balls must bounce off the edges of the world in such a way that the angle of incidence equals the angle of reflection.

  2. Each ball must move at a random speed in each of the X- and Y-directions, which speed may vary between 0 and 5 pixels per direction when the instance is created but stays constant for the lifetime of the ball.

Any tips on how to get started would be greatly appreciated, thanks!

0

There are 0 best solutions below