I’m working since a while to perfect an idea of mine, just some work done in spare time, nonetheless the dream of my lifetime, about a modular game engine that can be used for both 2D and 3D games.
The engine is completely object oriented, it is written in C++, and it is platform independent. To achieve this last goal, I’ve been using the SDL library v.2 and I plan to extend it to give full OpenGL support.
Games can be built by providing a list of objects that represent all the possible items used by the game: backgrounds, moveable physical objects, characters, tiles, and so forth.
Each object provides methods to update their status and position in the game, and to draw themselves on the screen. Drawing, in particular, can be achieved with different technologies, which can be plugged in the object classes by the mean of wrappers to the actual graphical interface. I start with providing wrappers for SDLv2 and, later on, OpenGL. More can come later, as the needs (and hopefully requests) arise.
The engine also supports a state machine, which states can represent specific scenarios of the game or game levels. Support will also be provided to play music and sounds, and to access external I/O resources, like keyboard, mouse, joystick, touch screen, and so forth.
All the game-specific objects and rules will be described in a XML configuration file, which is read by the engine during initialization. The engine itself should then be able to run the whole game. Here is how the modularity I mentioned at the beginning applies to this engine: the game developer only needs to take care of defining the various objects that are part of the game, the way they interact with other objects, and the rules of the game. Everything else will be taken care of by the engine.
In order to achieve the best performance, the game engine tries to avoid as much a possible the use of C++ libraries. Instead, the engine provides its own classes for data manipulation and other necessities, that are designed for speed and not for generalized usage. In fact, it is my opinion, supported by several performance measurements I took, that classes like, for example, the STL, pay the price of being too bloated and slow in order to remain highly generalized and usable.
I’m doing the main development under Linux, but given the cross platform portability of SDL and OpenGL, it should be possible to reuse the engine code, as is, on other platforms like Windows, OSX, and Android.
The whole engine will be developed under the GPL-2.0 license and will be publicly hosted on GitHub.
I will welcome any developer that may be interested in contributing to this project by refining its details and expanding its capabilities.
Most welcome is also any comment or suggestion anyone would like to provide.