logo
|
Always follow your heart and do things that makes you happy

Pong

This game is a clone of the classic Pong that was released in 1972 by Atari. I created this game in my own spare time to learn about game programming. I think this game would make it easy for me to develop and have a playable demo in rather short time.
/posts/pong/001-Start-Pong.jpg

Start Pong

/posts/pong/002-Score-for-the-right-player.jpg

Score for the right player

Technical Details
Initial StartedFebruary 23, 2012
Latest ReleaseDecember 08, 2012
LanguageC++
AudioFMOD
GUIMyGui
InputOIS
RenderingOGRE3D
Downloads
Microsoft Windows
Version 0.0.4December 08, 2012
GamePong-dev-v0.0.4-vc11.zip

The game is compiled with Microsoft Visual Studio 2012. Please install the Microsoft Visual C++ 2012 Redistributable Package if your Windows doesn't has the package installed.

OGRE RenderSystem Setup

OGRE RenderSystem Setup
The first time the game is started it will make some configurations, such as asking the user for a desired Render System and video settings.

Easy configuration:
Choose the OpenGL Rendering Subsystem and click on Accept. This will use the default configurations, such as starting the game in fullscreen mode and use the highest available screen resolution.

To display the "Setup Dialog" again, just delete the ogre.cfg. The settings are stored in the file.


Collision Detection
The collision detection algorithm is based on the lecture from the course "Advanced Game and Simulation Programming" at Narvik University College.
Pseudocode for the collision detection algorithm:
  • Calculate the physical properties (velocity, displacement, acceleration, etc.) for the ball and the paddles.
  • Looking for collision between the ball, the walls and the paddles. If any collision occur, create a collision object and register it in an array of collisions.
  • Make the array of collisions unique by removing duplicated collision objects.
  • Sort the array of collisions depending on the time of collision. The first collision should be handled first.
  • For every collision object in the array:
    • Pop the first element to handle.
    • Move the ball (or the paddle) to the point of impact.
    • Compute new physical properties.
    • Looking for collision between the ball, the walls and the paddles for the remaining time step. Register collision object into the array of collisions if any collision occurs.
    • Make the array of collision unique.
    • Sort the array.

Ball and Wall Collision

Sphere and wall collision

Collision equation
This collision algorithm "assume" that the wall is infinite, and is defined by a point q and a normal n. The ball is defined by a point p and a radius r.
In this time step the ball is moving along the ds vector. The point of impact is at the "time" x along that vector. So in order to find the x value, we will first find the d vector, which is defined from the center of the ball p to the point qn.

Then we will find the green and the purple vector. The green vector is defined from the center of the ball p to the "time of impact" xds. And the purple vector is defined from the center of the ball p to the point qn. Both the vectors are in the same direction as the normal of the wall.

x, by putting the green vector and the purple vector equals each other into an equation.

x <, n> n = <d, n> n

  • If x is in (0, 1], this would be the "time of impact".
  • If x n> 0, then the ball is moving away from the wall.
  • If x n< 1, then not a collision within this time step.
  • If the <ds,n> is equals approximately to zero, then the ball is moving parallel with the wall.

Development History
Version 0.0.4 (08/12-2012)
Support score limit at 10 scores.

Version 0.0.3 (27/06-2012)

Improvement of the score HUD

Improvement of the score HUD

Version 0.0.2 (28/04-2012)
In this is version the audio is supported. It plays sound when the ball hits the paddles or the walls, and when the player scores.

Version 0.0.1 (20/04-2012)
This is the first development version. Currently the game support only two players mode and has no score limit.

First version

First version