An open API service indexing awesome lists of open source software.

https://github.com/tupini07/raylib-cpp-cmake-template

A small Raylib C++ template that uses CMake, LDtk, and Box2d
https://github.com/tupini07/raylib-cpp-cmake-template

game-template raylib raylib-cpp

Last synced: 12 days ago
JSON representation

A small Raylib C++ template that uses CMake, LDtk, and Box2d

Awesome Lists containing this project

README

          

# Raylib C++ CMake Template



This repo constains a small game that you can use as a template for your Raylib
games if you wish to use C++ and CMake.

CMake is configured to automatically download the dependencies of your game
through git, and pin them to a specific commit version (for example, [see how
we're importing the raylib
dependency](https://github.com/tupini07/raylib-cpp-cmake-template/blob/11af0880cf10ecc31fc0d5d63e79650d205024a2/CMakeLists.txt#L25-L31)).
This provides a very flexible mechanism to include new dependencies, or update
the existing ones, without having to muck about with your system's package
manager, or worrying about linking external libraries at all. It is a bit slower
on the first build though, since CMake will need to build everything.

For the moment, the project is using the following dependencies which should be
useful in many games:

- [LDtkLoader](https://github.com/Madour/LDtkLoader) - used to load and help
with drawing a map made with the awesome [LDtk](https://ldtk.io/).
- [box2d](https://github.com/erincatto/box2d) - ubuquitous and easy to use 2D
physics engine.
- [fmt](https://github.com/fmtlib/fmt) - logging and string formatting library
that makes your life much easier.
- [raygui](https://github.com/raysan5/raygui) - a simple and easy to use
immediate mode GUI library that is built on top of raylib. Good for building
UIs and debugging tools.

If you don't know where to start or how to use this template then check out [the wiki](https://github.com/tupini07/raylib-cpp-cmake-template/wiki)!

## Important files

You can get a good understanding of how things work by reading through the
following files:

- [[main.cpp](https://github.com/tupini07/raylib-cpp-cmake-template/blob/11af0880cf10ecc31fc0d5d63e79650d205024a2/sources/main.cpp)]
this is, of course, the entrpoint of the game. It maintains a top-level frame
buffer to which all draw operations are done, and then this buffer is drawn to
the screen, with a specific scale (meaning you can easily scale and/or
translate your game without having to worry about the actual screen
resolution). It also calls the SceneManager's update and draw methods.
- [[SceneManager](https://github.com/tupini07/raylib-cpp-cmake-template/blob/11af0880cf10ecc31fc0d5d63e79650d205024a2/sources/scenes/SceneManager.hpp)]
Implements an extremly simple scene manager. It updates and draws the current
scene or switches to a new scene if necessary.
- [[TitleScene](https://github.com/tupini07/raylib-cpp-cmake-template/blob/11af0880cf10ecc31fc0d5d63e79650d205024a2/sources/scenes/TitleScene/TitleScene.cpp)]
This is the main screen that is shown when the game starts. It contains some examples
of raygui components.
- [[GameScene](https://github.com/tupini07/raylib-cpp-cmake-template/blob/11af0880cf10ecc31fc0d5d63e79650d205024a2/sources/scenes/GameScene/GameScene.cpp)]
This is the scene where the main _game_ happens. It's not really a game per
se, just a showcase of how you would set up a
[Player](https://github.com/tupini07/raylib-cpp-cmake-template/blob/11af0880cf10ecc31fc0d5d63e79650d205024a2/sources/entities/Player/Player.cpp),
draw an LDtk map, and add some physics to everything using Box2D.

# Questions and comments

If you have any question then feel free to [create a new discussion](https://github.com/tupini07/raylib-cpp-cmake-template/discussions/new), or if you see any issue then go ahead and [open a new issue](https://github.com/tupini07/raylib-cpp-cmake-template/issues/new).

If you see anything that can be improved then feel free to make a PR! Those are always welcome 🙂 Another welcomed contribution is that of going through the wiki and clarifying content or adding new things you think might be helpful for others.