![]() |
sunlight 0.31.0
A C++17 2D game engine library wrapping raylib and libtmx
|

sunlight is an open source library written in C++ to make 2D games. Overall, its present main features include a manager that can deal with map, collision, sprites and graphic primitives.IEngine interface (src/engines/) so a new backend only needs its own implementation plus one line in the engine factory, without touching the rest of the codebase. In order to make sunlight run as desired, it is necessary to install the dependencies listed below beforehand:
You may install the package on its official page. Higher versions are also supported.
For Linux
Ubuntu/Debian users can install the package by using the command apt-get on their Linux shell.
It is also recommended to install by using the standard package manager offered by your prefered distro.
For MacOS
Mac users may obtain the package through MacPorts or Homebrew.
Use vcpkg to integrate C/C++ libraries using Visual Studio.
By default, the project's CMakeLists will automatically search LibXML and its dependencies (LibIconv). For those who might want to use the library installed on your system, the following parameter should be used to call CMake:
zlib can be installed by using your standard package manager.
The installation steps for which OS are listed below.
PhysFS backs sunlight's virtual filesystem (mounting a loose directory or an archive so every resource read — textures, sound, tilemaps — goes through one path space). Like LibXML2/tmx/raylib, it is fetched and built automatically via FetchContent; no separate install is required.
You may find the detailed instructions by clicking here and following the steps regarding the operational system you're using.
By default, sunlight doesn't build the projects' samples.
In order to make it compile with samples, it is necessary to open the CMakeLists on the project's root to change the option from OFF to ON, as shown below:
>[!NOTE] >You may also use the following command line on your system's shell: >shell >cmake -DBUILD_LIBRARY_SAMPLES=ON >
Unit tests are also opt-in, using doctest fetched automatically via CMake:
>[!NOTE] >You may also run the tests through CTest: >shell >ctest --test-dir build >
If you intend to use VsCode as your IDE, follow the instructions shown here.
Each sample takes its own directory as argv[1] and resolves its resources relative to it, e.g.:
tilemaprenderer by adding an animated Sprite on top of the map.sprite by making the sprite player-controlled and colliding it with a static obstacle via CollisionManager.collision by giving two independent characters their own controller: one gamepad's left stick/DPad drives Sunny, the right stick/face buttons drive a second sprite.ScriptProcessor: queued commands load a stage, slide sprites on screen, and play/pause/resume a tone via SoundManager, exercising every control-flow command (WAIT_CMD, WAIT_SPRITES_QUEUE_EMPTY, LOOP_CMD/END_LOOP_CMD, LABEL_CMD/GOTO_LABEL_CMD).sunlight's multiple views (TileMapRenderer::CreateView) and world-space sprites (Sprite::SetWorldSpace).