Bounce Physics.


My first association with the topic title was the "Bounce"-physics in certain fighting games involving scantily clad females... but you're not programming one of those, are you? :-D

Anyway, I can't help you with your problem. Sorry.

But you should probably describe your problem in more detail. What kind of effect do you want to achieve?

Ball-bouncing like in Pong/Arkanoid? Or realistic ball-bouncing like throwing a ping-pong ball at a wall or on the ground?
 
Dryer Lint posted on Oct 1 2005 at 10:01 PM said:
My first association with the topic title was the "Bounce"-physics in certain fighting games involving scantily clad females... but you're not programming one of those, are you? :-D

Anyway, I can't help you with your problem. Sorry.

But you should probably describe your problem in more detail. What kind of effect do you want to achieve?

Ball-bouncing like in Pong/Arkanoid? Or realistic ball-bouncing like throwing a ping-pong ball at a wall or on the ground?
Pong style bounces.
 
Last edited by a moderator:
The angle of incidence is equal to the angle of reflection. If I recall correctly from my physics classes (damn that american 'talk' again). Basically, the angle a perfectly circular object hits a perfectly straight vertical wall, the angle it bounces off at will be 'negative' the angle it bounces of at.

Does that make any sense?

not to me either...but a few hacks later and it will work!

If a ball is coming in at 30 degrees to a vertical wall, it will bounce off at 180+30 degrees.

Just mess about until it looks right. That's scientific aint it?

sorry, i'm on my 3rd can of cider...
 
A way of doing it is described in the topic here.

-> Skippable blabla introduction
In general, bouncing isn't much more than calculating the angle of movement as a result of the angle of the surface you bounce on and the incoming angle of the ball. For Pong situations, there are 'shortcuts', easy routines, because all there is to it are 90 degree angles:

-> Easy solution
Code:
process ball()

private
ballspeed = 10;

begin

//insert graph, startvalues of variables and other blabla

loop
if(x > 320 or x < 0)
  angle = -angle;
end
if(y > 240 or y < 0)
  angle = -angle + 180000;
end

advance(ballspeed);
frame;
end

end

Basically, that's all there is to it.

EDIT: So yeah, what Miner49er said :)
 
Last edited by a moderator:
You'll probably want to change the angle of reflection slighly based on the ball's spin (off the paddle), or else you could get yourself locked in between a few bricks in an arkanoid-type situation.
 
by the way, Arkanoid and it's many derivitives, use the distance from the middle of the bat as the determining factor in the bounce angle (off the bat).
 
Back
Top