Built as part of a brief university games with C++ workshop, this simple 2D game-engine provides powerful features, including destructive terrain, rope-physics and more Fundamental ones, such as ray-casts, animations, parallax scrolling and basic physics.
Take a look at the video below to see it in action!
Note that certain elements of the demonstration above are heavily inspired by the Supreme Jeh'Oul bossfight from Wings of Vi (this one).
The whole project is open source and within the public domain. It can be found under this github repository. The only dependencies are SDL2 and SLD2-image.
A highly simplified overview of the underlying engine structure can be derived from this diagram:
As is typical in game-engines, most entities inherit from an underlying 'Object' class that provides a function to draw them on screen as well as update them on a per-frame basis. The Image class provides the visual element, whilst the physicsObj class provides rudimentary physics interaction such as gravity.
The terrain works with a bitmap on a per-pixel basis. The destructibility of any terrain pixel is given by a terrain mask. The terrain mask corresponding to the level in the above linked video can be seen here:
Note as well the purple border around the edges. Since the terrain also takes priority on the solidity of an object, this can be used to keep the player within the level's bounds.
The UML diagram below should give you a decent overview of the base classes. Keep in mind that advanced classes controlling enemies or the player are not depicted.
The respective source files for each class are neatly organized as follows:
The root directory contains what you might consider to be the 'game engine':
Includes more specialized files. All of these inherit from either the Object or Image class.
Point- and Path-classes used for the Navigation of the Boss. Paths can have ease-in/-out aswell as linear, bezier or sine-curve interpolations. nav_graph creates and includes preset paths for the boss to navigate along.
All classes concerning the boss.