A86: Re: pong type games


[Prev][Next][Index][Thread]

A86: Re: pong type games




Hehe.  One thing to remember when programming video games: if it looks good,
then it is good.  You don't need to use real physics when simple stuff will
do, especially on a calculator.

As for collisions, simple geometry tells you that for all elastic
collisions, the resulting angle will be the same angle as before the
collision, reflected over a line that is perpendicular to the line that was
hit.  In pool for example, when the ball hits a wall and the angle is say 10
degrees from the wall measured from the direction it's coming, the angle
will still be 10 degrees from the wall, but from the direction it's going.

Now, in pong, you're probably not going to be using angles.  You'll probably
keep track of the x and y velocities of the ball.  And all collisions will
occur on lines parallel to the x or y axis, making it much simpler.

If the collision is on a vertical surface, then you reverse the sign of the
x velocity.  Similarly, if the collision is on a horizontal surface, reverse
the sign of the y velocity.

I don't think I've ever seen a pong game that changes the ball's velocity
according to how the paddle is moving.  You shouldn't have to worry about
that.


>
> What equations are used in pong games???
> Assuming a perfectly elastic colision the the law of
> conservation of momentum applies but what about when
> the paddle is moving, or rather (de)accelerating?
> how is the velocity of the ball calculated?




Follow-Ups: References: