top of page
sprites.jpg
logoWallpaperDark_edited.jpg

Trinal Engine - 2022

2D Game engine

Simple 2D Game Engine Designed for Platformers

The Trinal Engine is my own custom game engine designed for quickly making platformer games. But any other 2D game would work too.

c++icon_dark.png

Im
GUI

sfml-icon_dark.png
About

The Trinal Engine is my attempt to better learn the systems that modern game engines use. Prior to this I have been making games using the Unity Game engine and have been fascinated by how it works. throughout making this C++ game engine I have enjoyed learning about the many algorithms that game engines use.

Component System:

The engine uses a game object and component system.

Each game object has a few values such as its transform, layer and name. Each game object also stores a list of components.

The scene class then contains a vector of layers, each containing a vector of game objects. The scene loops through all layers and game objects each frame, calling update on each component. The scene also manages the fixed update functions, that are called a fixed amount of times per second.

The user can create as many new components as they like by deriving from the component class. However, the game engine has a few built in components, such as colliders and rigidbodys, for 2D physics, circle, box and sprite renderers, and a camera component for drawing.

C++ Reflection

The engine editor works by using custom C++ reflection. Because C++ doesn't have reflection by default, the engine uses macros to achieve a similar result. The component base class, derives from a class that manages all reflecting. In each component header, you must call the declaration macro. Which will set up a static class, storing the class information. It will also set up a static function, to create an instance of the class.

In each component cpp file, the begin and end macro must be called. This initializes the class information and also the getClass function which will return the class information. In-between the begin and end macros all component variables that you want visible in the editor are then passed into another macro. this simply puts all variables into an array to be passed through in the end macro. When the class information is initialized, it loops through each variable, saving the memory offset and variable type to a map using the variable name as a key. It then passes itself to a static map of classes that use reflection. This means that any class or variables are accessable by name and can be iterated over.

The engine editor then utilizes this reflection to show all components and allow for values to be adjusted while the game is running.

Features
  • Modular physics

  • C++ reflection

  • It's a game engine

Screenshots

bottom of page