A lightweight 2D game engine written in C++20 with OpenGL 3.3 Core.
- Sprite rendering -- batched instanced drawing with orthographic projection
- Texture loading -- from files (stb_image) or procedurally generated solid colors
- Input -- keyboard via GLFW
- Audio -- sound loading and playback via SoLoud
- ECS -- entity-component-system with sparse set storage, built-in components for position, velocity, sprites, gravity, colliders, and tags
- Scripting -- Lua 5.4 integration via Sol2
- Fixed timestep -- 60 FPS game loop
All fetched automatically via CMake FetchContent:
- GLFW 3.4 -- windowing and input
- glad 2.0.8 -- OpenGL loader
- spdlog 1.15.3 -- logging
- GLM -- math
- stb_image -- image loading
- SoLoud -- audio
- Lua 5.4.7 -- scripting
- Sol2 -- C++/Lua binding
cmake -B build
cmake --build buildMinimal engine test -- draws a sprite, plays a sound, responds to keyboard input.
./build/helloworldA Mario-inspired 2D platformer demonstrating the ECS with physics, gravity, and AABB collision. Features a procedurally generated level with ground, floating blocks, pipes, a staircase, and a flagpole.
./build/platformerControls: Arrow keys or WASD to move, Space or W or Up to jump, Escape to quit.
src/
Engine.h/.cpp -- core engine, game loop
GraphicsManager.h/.cpp -- OpenGL rendering, sprites, textures
InputManager.h/.cpp -- keyboard input
SoundManager.h/.cpp -- audio via SoLoud
ScriptManager.h/.cpp -- Lua scripting via Sol2
ResourceManager.h/.cpp -- asset path resolution
Types.h -- common type aliases
ECS/
Entity.h -- EntityID type
Component.h -- component base, type IDs
Registry.h -- entity registry, sparse set storage
PositionComponent.h -- 2D position
VelocityComponent.h -- 2D velocity
SpriteComponent.h -- texture name + dimensions
GravityComponent.h -- gravity acceleration
ColliderComponent.h -- AABB dimensions
PlayerTag.h -- player marker
StaticTag.h -- static/immovable marker
demo/
helloworld.cpp -- basic engine demo
platformer.cpp -- 2D platformer demo
assets/
shaders/ -- vertex and fragment shaders
