Skip to content

lishacodesgames/Raylib-Modular-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raylib Modular Template

Modular game template using raylib as a git submodule and CMake.
This repository is intended to be used as a starting point for a new raylib project.

This library-based system is for those who want a distinct separation between the core app, external libraries, and gui code.
This can be used as-is (like I do) or any subdirectories can be added or removed as needed

I also have a simpler, non-lib-based, template: check it out

How to use

Clone

git clone --recursive to get the raylib submodule local

If you forgot, do:
git submodule update --init --recursive after regular git clone

Build & Run

mkdir build
cd build
cmake --preset Debug    # or: cmake --preset Release
cmake --build --preset Debug    # or: cmake --build --preset Release

./bin/<preset>/MyGame

Note:

  • for Windows, omit the ./ and add .exe at the end
  • Make sure you're running from the repo directory YourProject/
  • Make sure you have cmake and ninja in your path variables

Check out CMakePresets.json if you're confused

Project Structure

What your project architecture should ideally look like for the CMakeLists.txt I've included (Can change accordingly, otherwise)

‖
‖——.git*
‖——CMakeLists.txt
‖——CMakePresets.json
‖——App/
‖  ‖——CMakeLists.txt
‖  ‖——include/
‖     ‖——*.h    → all *your* header files
‖  ‖——src/
‖     ‖——main.cpp
‖     ‖——*.cpp  → all *your* source files
‖
‖——lib/
‖  ‖——raylib/   → raylib submodule
‖  ‖——Engine/   → my own (extremely simple) implementation
‖     ‖——GUI/   → raylib GUI stuff that's not native to your app
‖     ‖——Core/  → veryy simple Layering and Logging system

I would love some feedback and suggestions for the Engine!

Linux Dependencies

Raylib requires a lot of libraries that are built-in on Mac and Windows.
No worries, Linux just requires 1 command to install them all:

sudo apt install \
    libx11-dev \
    libxcursor-dev \
    libxrandr-dev \
    libxi-dev \
    libxinerama-dev \
    libgl1-mesa-dev \
    libasound2-dev \
    libpulse-dev \
    libxkbcommon-dev

Note: I've made it so that you don't need to touch any CMakeLists.txt to run
If any issues arise, lmk :)

Updating raylib (the submodule)

cd lib/raylib
git pull
cd ../..
git add lib/raylib
git commit -m "Updated raylib submodule"

Requirements

  • CMake 3.20+
  • Ninja (not required, but it's what the presets use)

About

A modular game template based on raylib with a separation of static libraries and the game itself. Raylib

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors