DreamEngine
A lightweight, modular 2D game engine built in modern C++.
Dream freely, build deliberately.
Let the engine run the loop.
Implement the scene’s hooks for input, updates, and drawing, then queue it with SceneManager. DreamEngine polls for events, measures the time between frames, and presents the finished frame.
Define how your game behaves.
In a survey scene, a scan reveals nearby signals and spends ten units of charge. You decide when a scan succeeds. The scene passes its updates and draw calls to a BarView, which draws the remaining charge and animates the trailing edge.
The scene declares its meter as BarView charge{100}. Its public fields control the fill color, outline width, and trailing delay.
void SurveyScene::onEntry() {
charge.foregroundColor = Color("#91D8C8");
charge.outlineWidth = 2;
}
void SurveyScene::scan() {
if (charge.currentProgress < 10) return;
charge.currentProgress -= 10;
revealNearbySignals();
}
Engine components
- Application Create the game window and run the main loop. Each frame, the loop routes input, updates, and drawing to the active scene.
- ResourceManager Load textures, audio, fonts, and video from a directory and retrieve each asset by name.
- SceneManager Queue the next scene. When the active scene allows a transition, the manager calls its exit hook and then the next scene’s entry hook.
- FiniteStateMachine Switch between behaviors such as patrolling and chasing. Each frame, the active state receives the update.
- Timer Run a callback after a delay or repeat it at regular intervals. Pause and resume the countdown as needed.
- CollisionManager Assign boxes to collision layers. When boxes on matching layers overlap, their callbacks define the response.
- Camera Follow a moving target with adjustable smoothing. Set parallax per layer to let distant scenery scroll more slowly.
- Animation Play frames from a sprite sheet at a chosen rate. Loop the sequence or attach a callback to the end of a one-shot animation.
- TextureSequence Divide a sprite sheet into equal-sized regions and look up a frame by index.
- VideoDecoder Decode a video file frame by frame and scale each frame to fit the game window.
- BarView Display health or charge as a progress bar. A trailing fill shows how much the value has dropped.
- Logger Write status messages, warnings, and errors to the console. Choose the minimum severity to display.
Game Demo
Revenants brings DreamEngine’s features together in a duel with the Ember Lord. The camera follows the swordsman, and each swing that connects takes a bite out of the boss’s health bar.
Next steps
I want to keep building components I can carry from one game to the next. A track-based AudioMixer would let a game fade the music while keeping sound effects at full volume. I’d like to add reusable UI views for menus and dialogue, support serialization so a scene can save and restore its state, and give games more control over how sprites, effects, and UI are drawn together in the rendering pipeline.