Breakout is back again! I decided to follow the traces that I left from the Pong adventures where I first created HTML5 version of the Pong and then re-implemented it with C++ and SDL2. This adventure brought some new aspects, which were not present in the Pong implementation. Let’s again see if I can manage to describe those in this post.

At the beginning…

It was quite easy to start this project as I already had the basis for the implementation structure from the previously implemented SDL2-Pong. I was also able to almost directly use the game logic from my HTML5-Breakout project. It was sure that some coding environment specific variables should be reconsidered but the main idea and logic still remain the same.

Game structure

The game structure was a quite similar than what we used in the SDL2 version of the Pong. All logical structures were divided into separate C++ classes which all lay within separate files. However, at this time we also used a bit more class inheritance to avoid unnecessary code rewrite by trying to follow the DRY (Don’t repeat yourself) principle.

The most significant change of the game structure was the rewrite of the main loop. The implementation uses a delta calculation to limit the logic execution (i.e. ticking) frequency of the main loop. This differs a bit from the SDL2-Pong which only limited the game logic execution speed only based on the monitor refresh rate. The new main loop structure used in this project should be logically consistent regardless to used monitor.



The implementation was a success, but I still consider some parts of the structure to be quite lazily implemented. Somehow, it feels like the event handling was a bit oddly placed within the logical structure of the ball and paddle instances. If I would rewrite the same game again, I would definitely put all logical functionality into a more centralized place. I think that perhaps it is time to start using a centralized event queue to handle game events as done typically in modern games. Let’s see if our next project will contain a some kind of implementation of that.

Thanks for reading!

Game source code in GitHub:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s