Turbo Engine 0.3
A C++ game engine using Allegro 5
Turbo Engine

Turbo Engine is a small, self-contained C++17 2D game engine built on Allegro 5**, organised around a classic Scene → GameObject → Component model. When built with Dear ImGui it ships a full editor (hierarchy, inspector, gizmos), a material / shader system and Lua scripting.

Building

Requirements: CMake ≥ 3.21, a C++17 compiler and Git. Every dependency (Allegro 5, Dear ImGui, Lua, sol2 and their transitive deps) is fetched and built automatically through vcpkg in manifest mode — no manual setup.

# Engine + demo, editor overlay OFF (default)
cmake -B build
cmake --build build
# With the full editor (Dear ImGui)
cmake -B build -DTURBO_ENABLE_IMGUI=ON
cmake --build build

The first configure compiles Allegro 5 and the rest from source through vcpkg, so it takes a while; later builds reuse vcpkg's binary cache.

Running the demo

Run demo from the build's bin/ directory — assets and the dependency libraries are deployed next to the executable, so it launches from anywhere.

Your first scene

A game is a turbo::Scene that builds a tree of turbo::GameObject. Each object has a turbo::Transform and, optionally, a turbo::Drawable (turbo::Sprite, turbo::RectangleShape, turbo::CircleShape) and turbo::Component behaviours. The turbo::Engine drives the window and the main loop; turbo::SceneManager owns the registered scenes.

#include <turbo/Engine.hpp>
class MyScene : public turbo::Scene {
public:
void load() override {
auto* root = new turbo::GameObject(nullptr, "Root");
auto* box = new turbo::GameObject(root, "Box");
box->set_position(400, 300);
box->set_drawable(new turbo::RectangleShape(120, 80, turbo::Color(220, 70, 70)));
this->root_gameobject = root;
}
void unload() override { delete this->root_gameobject; this->root_gameobject = nullptr; }
};
int main(int argc, char** argv) {
(void)argc; (void)argv;
turbo::Engine engine;
auto* scene = new MyScene();
engine.scene_manager.register_scene(scene, "Main");
engine.start_window("My Game", 1280, 720);
engine.loop();
engine.stop_window();
return 0;
}
Represent a color.
Definition Color.hpp:9
Main engine class.
Definition Engine.hpp:32
void stop_window()
Destroy the display and release the renderer.
Definition Engine.cpp:165
void loop()
Starts main loop.
Definition Engine.cpp:80
void start_window(const char *win_name, unsigned short width, unsigned short height)
Create the display, initialise the renderer (and the editor overlay when built with ImGui) and start ...
Definition Engine.cpp:152
SceneManager scene_manager
Owns the registered scenes and the active scene.
Definition Engine.hpp:105
Basic scene object.
Definition GameObject.hpp:19
Represents a drawable rectangle.
Definition RectangleShape.hpp:15
Basic scene class.
Definition Scene.hpp:11
virtual void unload()
Called when the scene is unloading.
Definition Scene.hpp:21
virtual void load()
Called when the scene is loading.
Definition Scene.hpp:16
void register_scene(Scene *scene, const char *name)
Register a scene in the manager.
Definition SceneManager.cpp:8
void set_active_scene(const char *name)
Set the scene currently displayed.
Definition SceneManager.cpp:15

Components

Behaviour lives in turbo::Component subclasses — override load(), update(int), on_enable(), on_disable(), unload() — and is attached with turbo::GameObject::add_component. The built-in turbo::component::SimpleControl moves an object with the arrow keys, for example.

Your first Lua script

Built with the editor, behaviour can also be written in Lua. Drop a file in assets/scripts/ that returns a table with optional lifecycle methods; self.gameObject is the owning GameObject:

local Rotator = {}
Rotator.speed = 90.0 -- editable in the inspector
function Rotator:update(dt) -- dt in milliseconds
self.gameObject:rotate(self.speed * dt / 1000.0)
end
return Rotator

Attach it from the inspector (+ Add Script) and press Play. The bound API (spawn / find / destroy, transform, input, materials, …) is provided by turbo::script::ScriptEngine; the component wrapper is turbo::LuaComponent.

Where to go next