0

Hi everyone!
I would like to make an Air Hockey game in pygame.
I was wondering if it was possible to have 'proper' bouncing (ie. the puck goes in a direction relative to the angle the paddle hit it in).
I can easily write the rest of the code.

Thank you
Mark

2
Contributors
6
Replies
15
Views
7 Years
Discussion Span
Last Post by SgtMe
-1

google 'air hockey game'.
then play one.

The problem is, the angle that the puck moves in after you hit it at a certain angle with the paddle. It's all the angles!

-1

I have found some games.

You must add the paddle's momentary velocity to the pucks velocity*-1 in a vectorial way.
That means if the paddle is not moving, then the velocity of the puck after the hit is -1*velocity before the hit. As expected.

-1

well that as well.
But, as i said in the 1st and 3rd post, its the angle that the puck moves in after you hit it at a certain angle.

0

If you have the velocity vector you have the angle of it.

If the puck comes in with the velocity vector (-1,-2), and the paddle is moving with (3,4), then the velocity vector of the puck will be -1*(-1,-2)+(3,4)==(4,6)
The angle of (4,6) is arcus tangent (6/4), or any other arcus trigonometric function can be used.

-1

Thanks...theres one problem.
Im 13, and ive just had dinner.
Could you explain the equation in a simpler way please?

Thanks anyway :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.