Lightweight, cross-platform 2D game library for C++
APACHE-2.0 License
#include <imgui.h>
and use itcerlib does not provide
In short, cerlib lets you define your game architecture however you desire. It does not impose a strict model on the game's code. It provides every basic audiovisual aspect necessary to develop a 2D game.
#include <cerlib.hpp>
#include <cerlib/Main.hpp>
struct MyGame : cer::Game {
MyGame() {
window = cer::Window{"My Game Window"};
}
void load_content() override {
image = cer::load_image("MyImage.png");
}
bool update(const cer::GameTime& time) override {
// Update game logic. Use the time parameter as a reference point for
// how much time has passed since the last update:
// ...
return true;
}
void draw(const cer::Window& window) override {
// Draw game content into 'window':
// ...
cer::draw_sprite(image, {100, 200}, cer::white);
}
cer::Window window;
cer::Image image;
};
int main() {
// Create & run our game.
return cer::run_game<MyGame>();
}
This is for those who want to get started quickly. It assumes that you have a working C++ 20 toolchain and editor / IDE already.
First, clone the repository:
git clone https://github.com/cemderv/cerlib
cd cerlib
The easiest way to start is to open the mygame
folder in the editor / IDE of your choice. It must support CMake-based projects. You should then be able to select a preset such as debug
and directly hit play and run your game.
cd mygame
cmake --workflow --preset debug
For a detailed introduction and tutorials, please visit the Getting Started page.
OpenGL | OpenGL ES / WebGL | Metal | |
---|---|---|---|
Windows | ✅ (≥ 3.0) | ||
Linux | ✅ (≥ 3.0) | ||
Android | ✅ (≥ ES 3.0) | ||
Web | ✅ (WebGL 2) | ||
macOS | ✅ (≥ 3.0) | Planned | |
iOS | Planned | ||
visionOS | Planned |
Windows | macOS | Linux | |
---|---|---|---|
x64 | ✅ | ✅ | ✅ |
x86 | ✅ | ✅ | |
ARM64 | ✅ | ✅ | ✅ |
RISC-V | ✅ |
cerlib has been tested and is confirmed to work with the following compilers:
Please see Contributing for further details on how to contribute to cerlib.