3 Replies Latest reply on May 26, 2012 4:16 AM by Ned Murphy

# Ball Movement

Hi All,

I am developing a double bouncer  game below is the requirement.

• There are two pads on the top boundary and the bottom boundary.
• The pads are perfectly aligned horizontally.
• The player can move both the pads left and right using the L/R arrow keys.
• There is a ball that initially rests on the bottom pad.
• As soon as the player moves the pad for the first time, the ball is set into motion.
• The ball’s speed increases progressively with the next level.
• Level complete after every 100 points.
• The player has to prevent the ball from going out of the top and bottom boundaries.
• The left and right boundaries act as walls and the ball bounces off them.
• The two pads control the angle of bounce of the ball depending on whether they are moving or not when the ball collides with them.
• If they are moving in the direction of the bounce, the bounce angle is increase.
• If they are moving against the direction of the bounce, the bounce angle is reduced.
• The game auto-generates squares at random locations in the empty space in between.
• All the values should be read from XML file. (e.g. speed of ball, level points)
• On clicking restart button, game should be reset to initial position.
• Use any background music in loop.
• Every time the ball bounces off a square, the player gets +10 points.
• The square is removed.
• A new square is added randomly in the empty space
• Use primitive shapes for all the objects.

In this i had a doubt how can i increase the ball bounce angle if pad and ball moving in same direction and how to reduce the ball bounce angle if the pad and ball is not moving in same direction how can i detect whether the ball and pad moving in same direction or not.

Regards

Kiran

• ###### 1. Re: Ball Movement

You should be able to use the arrow keys to determine which way a pad is moving (if it is moving).  And you should be able to use the increase/decrease in the x property to determine which way the ball is moving.

• ###### 2. Re: Ball Movement

Hi Ned Murphy,

Thanks for the quick reply. But here ball doest not move according to the pad direction Ball has it's own angle. If the ball is nearing to the pad we need to increase the ball bounce angle and vice versa.

How can we calculate ball is nearing to pad or not

Thanks

Kiran

• ###### 3. Re: Ball Movement

I don't see where needing to know how close you are to the pad has anything to do with what happens when the two objects are touching.  You won't be calculating the bounce until they touch.