Giter VIP home page Giter VIP logo

raylib-cpp-cmake-template's Introduction

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). 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!

Important files

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.

Questions and comments

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.

raylib-cpp-cmake-template's People

Contributors

mdorier avatar tupini07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

raylib-cpp-cmake-template's Issues

Segfault when exiting the game

I haven't looked at the code yet, only tested on my Mac, and it Segfaults when I press escape to close the game. Here is what's printed on the console:

raylib-cpp-cmake-template(6419,0x1dc7d5ec0) malloc: *** error for object 0x6000030053e0: pointer being freed was not allocated
raylib-cpp-cmake-template(6419,0x1dc7d5ec0) malloc: *** set a breakpoint in malloc_error_break to debug
[1]    6419 abort      build/raylib-cpp-cmake-template

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.