[C# (XNA)] Pong Physics Help?

Weegee

Go Weegee!
Reaction score
102
Hey everyone, I have a question regarding a pong game I am making in C#: What is a good way to do the physics in a pong game? It's just a simple pong game with 2 paddles and a ball. To make things easier, I made the "ball" square. Anyone got any ideas, math equations, code, etc to help me out?

Much Thanks! :thup:
 

Xienoph

You can change this now in User CP.
Reaction score
43
Actually, making the ball square instead of circle makes it more complicated, since you have less symmetry.

I don't have any equations / codes handy, but most of them are simple high school geometry anyway. The biggest problems are detecting and handling collisions, both of which require quite complex solutions.

So, you should use an existing physics engine. The one I've used for XNA is Farseer. It's well documented and easy to use.

Some things to consider. These will affect how complicated your collision detection / handling will be:
- Do you want accurate physics simulation? As in, friction, energy loss during collision, etc.
- What is the maximum speed of the ball? Is there a maximum speed?
 

UndeadDragon

Super Moderator
Reaction score
447
If you want really simple pong then you can just times the xSpeed or ySpeed by -1 when it collides with a paddle, this will make it appear to rebound at the correct angle.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top