Artificial Intelligence Depot
Visiting guest. Why not sign in?
News, knowledge and discussion for the AI enthusiast.
FEATURES COMMUNITY KNOWLEDGE SEARCH  
Physic ( Jezzball)
 
• Physic ( Jezzball)

I am working on a game like jezzball! I have some problems to let the ball realistic bounce. Can anybody help me I need to program a real physic!

Thanks you!

Martin

1 posts.
Saturday 24 May, 12:23
Reply
• Bouncing Balls

I have not really looked into making balls bounce, but this should give a reasonable result with regard to the size of the bounce:

Moving objects have energy and this is called "kinetic energy".

Balls bounce with what is called an "elastic" collision, meaning that some of the ball's energy will be lost in each bounce. For a realistic effect the amount of energy lost should be the same proportion each time. You should decide whether or not you want this degree of realism - many games involve bouncing balls that never lose energy - i..e they would keep bouncing forever without losing speed.

If you want to program elastic collison type bouncing:

Calculate the kinetic energy of the ball using this equation:

Kinetic energy = 0.5 * mass of ball * speed * speed

At each bounce, have the ball lose the same faction of its kinetic energy.

e.g. If you decide the ball will lose one third of its kinetic energy in each bounce then 2 third are left, so calculate the kinetic energy as it hits the surface and then multiply this by two thirds. This is the kinetic energy that is left. Then use the above equation to get the new speed back:

speed = square root of (2 * kinetic energy / mass of ball)

and do this for every bounce.

Dealing with the angle of the bounce is also quite simple. Just arrange for "the angle of incidence to equal the angle of reflection"

i.e. calculate the angle between the ball's trajectory and the surface it hits and ensure that when it bounces it has the same angle. For horizontal and vertical surfaces this would be very simple - if the surfaces can be at different angles then you would need to know some trigonometry.

Another issue: is there any gravity? As an object moves upwards its speed is reduced as its kinetic energy is converted to what we call "gravitational potential energy".

42 posts.
Sunday 25 May, 01:19
Reply
• About bouncing balls

You replied to a guy last year wrt to a bouncing balls problem....Can I ask wether you know anything about trig?
In a bouncing balls app that I am building the code is:

picBall.Top=Cint((Me.Client Rectangle.Height-picBall.Height)*(1-Math.Abs(Math.Cos(Math.PI*NBOUNCES*picBall.Left/Me.ClientRectangle.Width)))

controls the balls angle of bounce. But is it constant? ie angle of incidence = angle of reflection.
And why would TAN of the angle not be used?

2 posts.
Wednesday 13 April, 05:08
Reply