A proof of concept of using hot reload with the Raylib library in C.
-
Clone the Repository: Clone the repository with submodules:
git clone --recurse-submodules https://github.com/somenoe/raylib-hot-reload-c.git
-
Prepare Raylib: Run the library setup script:
./lib.bat
-
Run the Development Script: Build and run the game with hot reloading:
./dev.bat
This system uses three key parts:
- Main Executable: This is the main program that runs the game loop. It manages all game data.
- Game Code Library: This is where you write your game logic. It's a special library that can be updated while the game is running.
- Raylib Library: This is a library used to create the game. It is linked to the main program before the game starts.
The main program loads the Game Code Library while the game is running. It constantly checks if the Game Code Library has been updated. If an update is detected, the program loads the new library, allowing you to see your changes immediately without restarting. The Raylib Library remains connected to the main program, so it works seamlessly with the updated code.
-
Build: Compile the game code:
./build.bat
-
Run: Launch the game:
./run.bat
-
Update: Recompile and update the running game (hot-reload):
./update.bat
-
Watch: Automatically update the game when source files change:
./watch.bat
- Original Hot-Reload Template: https://github.com/krzosa/raylib_hot_reload_template
- Hot-Reloading Inspiration: https://hero.handmade.network/episode/code/day021/
- Git Submodules Explained: https://gist.github.com/gitaarik/8735255
- Raylib Library: https://github.com/raysan5/raylib