Coong was the first game that I wrote from scratch only in C++ and without the help of a game engine.
The name Coong is a combination of the words "Pong" and "Coop". Coong is a spin-off of the old "Pong" classic and offers the possibility to play together with a friend against the computer.
Player 1 has only the upper half to cover with his paddle and player 2 only the lower half. The tricky part is that the paddles can disappear at irregular intervals and the players have to remember the location of their paddles. On top of that, the ball speeds up every time it hits the paddle. Once the players or the computer reach four points, the game is over and ends automatically.
Button | Movement | |
---|---|---|
W | Player 1 Movement UP | |
S | Player 1 Movement DOWN | |
O | Player 2 Movement UP | |
L | Player 2 Movement DOWN |
This UML chart visualizes the dependencies of the individual classes and structures.
Since Coong does not run in a game engine and therefore there are no automated colliders, the collision has to be calculated by yourself. Fortunately, there is a library called "Simple DirectMedia Layer", which creates rectangles. In Figure 2 you can see the function that returns a boolean if a point of one rectangle touches or overlaps the other.
To make the function understandable, I have shown in Figure 3 a visual representation of the two rectangles, which can be for example the player's paddle (R1) and the ball (R2). The function checks if one of the four points (circled in red) touches or overlaps with the paddle.
As mentioned before, this function calculates if there is a collision between the ball and the player's paddle. This function can then update the speed of the ball by calculating the position between the player's paddle and the ball (Figure 4). However, since there are problems if the ball moves too fast I have defined a maximum value for the speed in the function.
Link to the repository: https://christian-brueckl.de:8443/svn/Coong/
_________________________
Username: showcase
Password: showcase