An OpenGL 4.4 game made with Entity-Component-System design pattern.
The structure of this project is being improved in my next C++ game Roll Goal. The main changes are : improved state machine with the pushdown automaton structure, the replacement of most events by singleton components, a render queue for the renderrer and an more elaborate and maintenable structure for rendering (materials, layers, ...).
You must install CMake and a C++ compiler which handles C++ 14. More on the compiler on the next sections.
The project need your graphic card driver to be up to date, as it is using OpenGL 4.4 core profile (released in 2013, so it should be fine).
The recommended compiler is g++, minimum version required is
g++ 6.1, which is included by default on many linux distribution. You can update it with :
sudo apt-get install build-essential
You will also need the OpenGl and SDL2 packages.
sudo apt-get install libsdl2-dev sudo apt-get install libglu1-mesa-dev mesa-common-dev
The recommended compiler is MSVC. To install it you will need Visual Studio (which is not VSCode) and select the C++ development package during installation. The MingW compiler will work as well if you prefer to use it.
CMakeLists.txt file ensure that the project will work on Linux and Windows platforms.
You can build and launch the project in many different ways, we covered a few of them :
Option 1: Bash (Linux only)
Go to this folder with a terminal, and enter those commands.
cmake . make ./bin/imac-tower-defense
It means that you are genererating a Makefile, then using it to build the project, and finally running the binaries from the current working directory (needed to find assets).
Option 2: Visual Studio (Windows only)
From Visual Studio 2017, you don't need to generate a visual studio project with cmake. You can simply open visual studio, browse the toolbar to File->Open->Cmake... and select the
CMakeLists.txt at the root of this directory. From this point, you have to make sure that you are using a x86 build configuration, and running the imac-tower-defense target. If everything is done, simply press
f5 or click on the green arrow at the top.
If you add files, you will need to re-generate the cache for a successfull build. To do so, right click on
CMakeLists.txt and use
Generate Cache for imac-tower-defense
Option 3: VSCode
You will need the
CMakeTools extension from vector-of-bools. If you want to change the source code, I highly recommend using the
C/C++ extension from Microsoft and the
CMake extension from twxs.
From this point, when you will open the repository folder with VSCode, it will prompt you to configure the projet. You must select a x86 kit, for exemple the
Visual Studio Community 2017 - x86 kit. Once the configuration is done, you can compile the project by pressing
f7. The .exe file will be outputed in
build/Debug folder. You can launch it by pressing
f5, but make sure to pick your operating system.
Before launching the compiled binaries, make sure that the working directory is set to this folder, or the shaders files and images will not be found by the program. If you are unsure about how to do it, just copy the builded files to this folder before launching them. (by default, they will be in the
The project follows the Entity Component System design pattern. It has been made possible with the great ENTT library.
Our game is concieved as a state machine, and works like this architecture :
||Entry point of the game|
||Struct of data for entities|
||Creation of complex components|
||Classes used to build entities|
||Struct of data defining event types|
||Wrapper classes for OpenGL objects|
||User interface logic|
||Error and log handlers for the game|
||Functionalities needed anywhere, like playing a sound|
||Update the game and the entities based on their components (all the game logic is there)|
|core||Constants, Game state machine and map loading|
||The different states of the game (title menu, in-level, game over, ...)|
||Read .ITD and .PPM files, and construct a graph from them|
|res||Ressources loaded at runtime|
||Musics and sound effects used accross the game|
||Fonts used accross the game|
||XAML files describing the view for each user interface|
||Images and spritesheets used by the game|
||.ITD and .PPM describing the levels of the game|
||GLSL shaders used by openGL for rendering|
Jules Fouchy - Processing star
Cyrielle Lassarre - Designer of the worlds
Guillaume Haerinck - Coding maniac