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). 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 - used to load and help with drawing a map made with the awesome LDtk.
- box2d - ubuquitous and easy to use 2D physics engine.
- fmt - logging and string formatting library that makes your life much easier.
If you don't know where to start or how to use this template then check out the wiki!
You can get a good understanding of how things work by reading through the following files:
- [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] Implements an extremly simple scene manager. It updates and draws the current scene or switches to a new scene if necessary.
- [TitleScene] This is the main screen that is shown when the game starts. It doesn't contain much, just a keypress listener to switch on to the actual GameScene.
- [GameScene] 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, draw an LDtk map, and add some physics to everything using Box2D.
If you have any question then feel free to create a new discussion, or if you see any issue then go ahead and open a new issue.
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.