Close

September 27, 2019

C++ Game on STM32F4

Recently I spoke about cross platform C++ development and provided an example project to help folks get started. At the other end of the scale, I introduce a C++ game for STM32F4 target. Specifically, I demonstrate how to write a simple game for the STM32F429I-DISC1 board. Most of the same principles apply when targeting embedded systems.

For resource constrained systems (and many times for reliability, here also), dynamic object creation is avoided or minimized An example in this game, a resource pool of bullets is maintained, rather than deleting old bullets and creating new ones.

.

I use CMake for most projects, and for STM32 targets I use stm32-cmake. To avoid destroying the blue User button, bullets are fired automatically. Left and right movement is controlled by the onboard L3GD20 ST-MEMS motion sensor 3-axis digital output gyroscope. Simply tilt the board around its long axis to move the player’s ship. You can use the blue button to reset the central position of the Player’s ship if required. My son uses it as a quick teleport away from incoming aliens if they get too close to him 🙂

Anyway, check out the project, and try out the game.

Cheers ..