Although C++ is quite a common language in professional game development, it is often considered to be quite the overkill for writing a simple 2D game like the one I’m making for my arcade cabinet, but still I chose C++. To be honest, it wasn’t my first choice, as I first used Python with Pygame. It worked fine on my laptop, but when I tried to draw even one single image on my Raspberry Pi, the framerate dropped to a staggering 7 FPS.
So I started optimizing; I transformed my costly PNG’s to BMP’s and used colorkeying instead of alpha channels, and used some pygame-specific optimizations like
surface.convert. It worked, the framerate went up to a steady 30FPS, until I started drawing the second parallax background, when the FPS dropped to 14. So maybe this was just a problem with the Raspberry Pi, perhaps the device can’t cannot draw 2 800x480 BMP’s, but it can run Minecraft, heck, the thing runs quake 3, so something must have been wrong with my code.
So I tried using C++ and the excellent SDL 2 library (actually, pygame is based on SDL 1.0), and the framerate remained a steady 30, even when I drew all 4 parallax layers (I used hardware scaling instead of soft scaling, so that could have been one of the issues), but even when I have about 100 enemies on screen, everything still runs buttery smooth. C++ was the first “real” programming language I learnt after Game Maker, so experience won’t be a problem, and I personally think it is a beautiful programming language when you ignore some parts of it and don’t treat it like it’s Java and try to cram every bit of clearly not OOP-code into a class, which essentially leaves you with C + classes + the STL (see what I did there?) . So perhaps C++ is still overkill and something like Java would’ve done, but it does what it should do and it does it good, and in the end, isn’t that everything that matters?