This site requires JavaScript, please enable it in your browser!
Greenfoot back
Lesedi
Lesedi wrote ...

2015/6/16

Problem with making balls bounce off world edge

Lesedi Lesedi

2015/6/16

#
Here is my problem: 1. 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. 2.The balls must bounce off the edges of the world in such a way that the angle of incidence equals the angle of reflection. I am struggling the most with the second problem. Any help will be appreciated. Thanks.
davmac davmac

2015/6/16

#
Is the problem that you don't understand what it means, or you don't know how to achieve it?
danpost danpost

2015/6/16

#
Remember that you are considering the horizontal and vertical (axial) movement separately. Hint: movement is a product of speed and __________? (you will need fields for both when considering each axis) Hint2: which of these two factors change when a bounce occurs? and how?
You need to login to post a reply.