Pong C++

  • Category: PC/C++ prototype
  • Project date: May, 2021
  • Git Repository: GitLab
  • Exe: Download

THE REASON

After taking some courses for C ++ (you can check them out here) I decided to do some practice on my own.

While following a tutorial everything seems clear and obvious to you, but when you try to create something from scratch ... difficulties arise!

So I decided to practice with a simple project like Pong because there are a lot of materials and tutorials online, so in case of difficulty, I could have easily check how to overcome them without struggling on simple things just because of using a language that I'm still learning.



TECHNICAL CONSIDERATIONS

The project is made completely with C++* from scratch using SFML 2.0 to manage the graphics.

* C++ 17 - std::clamp function is the only feature I used from C++17. Defining a custom implementation of it allows the project to run at least with C++ 14 (I have not tested the previous versions).



THE GAME

Everyone knows about Pong (at least everyone should!). Basically, there are two pads and each player controls one to hit the ball, causing it to bounce backwards. The goal is to score the other player. The ball can bounce off the horizontal edges of the screen, but not the vertical ones where a goal is detected.



HOW TO PLAY

You can play with 3 different modes:

  • 1 vs 1: Left player uses W and S to move the pad, while the right one uses Up and Down arrows.
  • 1 vs CPU: You can play against the CPU. You control the left pad (with W and S) while the CPU moves the right one.
  • CPU vs CPU: Basically you watch the CPU playing against himself (and unless you change the current set of parameters - like the ball and pads speed - it's more like a screen sever than a game mode!)