Lite2D is a compact, easy-to-understand 2D game engine written in modern C++ (C++17) using SDL2.
Designed for learning and quick prototyping: no advanced IT skills required.
- Open a terminal (or PowerShell on Windows).
- From the project folder:
mkdir -p build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release
- Run the executable:
- Linux / macOS:
./lite2d
- Windows (PowerShell):
.\Release\lite2d.exe
- Linux / macOS:
If you prefer a single copy-paste on Linux:
git clone <repo> && cd Lite2D && mkdir build && cd build && cmake .. && cmake --build . && ./lite2d- C++ compiler supporting C++17 (GCC, Clang, MSVC)
- CMake >= 3.10
- SDL2 development libraries
Quick install examples:
- Ubuntu / Debian:
sudo apt update sudo apt install build-essential cmake libsdl2-dev
- Fedora:
sudo dnf install gcc-c++ cmake SDL2-devel
- macOS (Homebrew):
brew install cmake sdl2
- Windows:
- Use vcpkg:
vcpkg install sdl2and pass-DCMAKE_TOOLCHAIN_FILE=.../vcpkg.cmaketo CMake.
- Use vcpkg:
- Minimal ECS-ish design (Entity + Components)
- Delta-time movement for smooth, frame-rate independent motion
- Simple rendering of colored rectangles using SDL2
- Basic collision detection and bounce response
- Easy configuration: background color and FPS via Engine API
- Beginner-friendly sample entities (Player, Enemy, Obstacle)
- Close window or press
ESCto exit. - Sample entities demonstrate movement, wrapping at screen edges, and collisions.
- CMake reports "SDL2 not found":
- Ensure
libsdl2-dev(Linux) orsdl2(Homebrew) is installed. - On Windows ensure CMake can find SDL2 or use vcpkg toolchain.
- Ensure
- Runtime: missing SDL2 shared library (.so/.dll):
- Linux: install SDL2 runtime or set LD_LIBRARY_PATH to the SDL2 location.
- Windows: place SDL2.dll next to the executable or add its folder to PATH.
- Build errors about C++ standard:
- Ensure your compiler supports C++17. Add
-std=c++17if needed.
- Ensure your compiler supports C++17. Add
- src/main.cpp — app entry and simple config
- src/Engine.h / src/Engine.cpp — main loop, input, update, render
- src/Entity.h — entity container
- src/Components.h — transform, render, velocity, collider, tag
- CMakeLists.txt — build configuration
To add or customize content (very simple):
- Edit
Engine::CreateEntities()to add new squares, colors, velocities. - Change background or FPS in
main.cppusingengine.SetBackgroundColor(...)andengine.SetFPS(...).
This short guide shows the simplest ways to run, play with, and lightly customize Lite2D — no deep IT skills required.
-
Run the app (already built)
- From the project folder:
- Or double-click the
lite2dexecutable in your file manager (Linux) after building.
-
Play
- The window shows simple colored squares.
- Close the window or press ESC to quit.
-
Change the background color or FPS (no strong programming needed)
- Open
src/main.cppin a text editor (VS Code, Notepad++, gedit). - Find these lines and change the numbers:
engine.SetBackgroundColor(20, 20, 40); // r, g, b (0-255) engine.SetFPS(60); // frames per second
- Save and rebuild:
cd build cmake .. cmake --build . ./lite2d
- Open
-
Add or edit a square (super simple)
- Open
src/Engine.cppand findEngine::CreateEntities(). - Copy one of the example entities and tweak values:
auto myBox = std::make_unique<Entity>(); myBox->transform = std::make_unique<TransformComponent>(100.0f, 120.0f, 40, 40); // x, y, width, height myBox->render = std::make_unique<RenderComponent>(255, 200, 0); // r, g, b (0-255) myBox->velocity = std::make_unique<VelocityComponent>(0.0f, 0.0f); // vx, vy (pixels/sec) myBox->tag = std::make_unique<TagComponent>("MyBox"); entities.push_back(std::move(myBox));
- Save, rebuild, and run to see the new square.
- Open
-
Tweak movement without advanced code
- velocity vx (positive = right, negative = left), vy (positive = down, negative = up).
- Larger absolute numbers = faster movement.
-
Remove an object without deleting code
- Set visibility to false:
entity->render->visible = false; - Or mark for deletion at runtime:
entity->Destroy();
- Set visibility to false:
-
If something goes wrong
- Copy any terminal error and ask for help (paste the text).
- For SDL2 missing errors, follow the Prerequisites section to install SDL2.
Contributions and questions are welcome. Suggested workflow:
- Open an issue to discuss larger changes
- Submit small, focused pull requests
- Add comments for new logic and simple examples/demos
MIT — see LICENSE file.