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

2012/12/7

Make the ball bounce in pong

Rodin10 Rodin10

2012/12/7

#
Hello everybody, I'm trying to make pong in Greenfoot but I'm very new to it. I want to make the ball bounce when it hits the wall. I'm trying to change the rotation but I have no idea how I should do it. Thanks in advance
danpost danpost

2012/12/7

#
For a bounce off the left and right walls (vertical surface), use:
setRotation(540-getRotation());
For a bounce off the top wall (horizontal surface), use:
setRotation(360-getRotation());
Of course, the bottom wall in Pong is treated differently.
Rodin10 Rodin10

2012/12/10

#
Thanks :)
You need to login to post a reply.