Pong

I decided it was high time I learned how to program in C++, and figured the best way to do so would be to write some games of my own. When I started this project I made it clear to myself that I not only wanted to learn the language, I wanted to see what it was like to actually finish a game. You know, not just start the project, wallow around in it, and then move on to something new, but actually finish it. This inevitably led me to focus my efforts on something smaller and more reasonable that I could complete. But what sort of game could I expect to finish in a few weeks? Yup. Pong.

Pong is my first completed game. I used Allegro 5, a nice C++ game library, as a framework to build on top of and now have a neat executable that plays well.

 

The game is about as simple as it gets, but that was the point. There was plenty to learn just in getting used to C++'s syntax, and figuring out how to deal with memory management and iterators was a pain. It was well worth it though, and I have already gotten a lot better.

I event came up with a neat implementation of text. The 'Pong' font I came up with creates every letter / digit out of blocks in a 3x5 grid. This makes 15 blocks per character, with 1 block spacing in between. Each character essentially has 15 bits of information, one for every block, and so I basically mapped chars to uint16 bitmaps representing which blocks were lit. Pretty elegant, and it could be scaled freely, as seen above.

As always, code is available. To play the game, download the executable + resources here (rename the extension "rename" to "exe" in order to run it). The source code is here.

My C++ adventure isn't over yet. Next game: Asteroids!