This is an Odin + Raylib game template with Hot Reloading pre-setup. It makes it possible to reload gameplay code while the game is running. I have made as a mix of Karl Zylinski Odin Template and Randy Prime Blueprint
- Run
build_hot_reload.shto creategame_hot_reload.bin(located at the root of the project) andgame.so(located inbuild/hot_reload). Note: It expects odin compiler to be part of your PATH environment variable. - Run
game_hot_reload.bin, leave it running. - Make changes to the gameplay code in
source/game.odin. For example, change the linerl.ClearBackground(rl.BLACK)so that it instead usesrl.BLUE. Save the file. - Run
build_hot_reload.sh, it will recompilegame.so. - The running
game_hot_reload.binwill see thatgame.sochanged and reload it. But it will use the sameGame_Memory(a struct defined insource/game.odin) as before. This will make the game use your new code without having to restart.
Note, in step 4: build_hot_reload.sh does not rebuild game_hot_reload.bin. It checks if game_hot_reload.bin is already running. If it is, then it skips compiling it.
Run build_release.sh to create a release build in build/release. That bin does not have the hot reloading stuff, since you probably do not want that in the released version of your game. This means that the release version does not use game.so, instead it imports the source folder as a normal Odin package.
build_debug.sh is like build_release.sh but makes a debuggable executable, in case you need to debug your non-hot-reload-exe.
build_web.sh builds a release web executable (no hot reloading!).
- Emscripten. Download and install somewhere on your computer. Follow the instructions here: https://emscripten.org/docs/getting_started/downloads.html (follow the stuff under "Installation instructions using the emsdk (recommended)").
- Recent Odin compiler: This uses Raylib binding changes that were done on January 1, 2025.
- Point
EMSCRIPTEN_SDK_DIRinbuild_web.sh/shto where you installed emscripten. - Run
build_web.sh/sh. - Web game is in the
build/webfolder.
Note
build_web.sh is for windows, build_web.sh is for Linux / macOS.
Warning
You can't run build/web/index.html directly due to "CORS policy" javascript errors. You can work around that by running a small python web server:
- Go to
build/webin a console. - Run
python -m http.server - Go to
localhost:8000in your browser.
For those who don't have python: Emscripten comes with it. See the python folder in your emscripten installation directory.
Build a desktop executable using build_desktop.sh/sh. It will end up in the build/desktop folder.
There's a wrapper for read_entire_file and write_entire_file from core:os that can files from assets directory, even on web. See source/utils.odin
See the README of the Odin + Raylib on the web repository for troubleshooting steps.
You can put assets such as textures, sounds and music in the assets folder. That folder will be copied when a release build is created and also integrated into the web build.
The hot reload build doesn't do any copying, because the hot reload executable lives in the root of the repository, alongside the assets folder.
You can hot reload while attached to RAD Debugger. Attach to your game_hot_reload executable, make code changes in your code editor and re-run the the build_hot_reload script to build and hot reload.
The template works nicely together with my atlas builder. The atlas builder can build an atlas texture from a folder of png or aseprite files. Using an atlas can drastically reduce the number of draw calls your game uses. There's an example in that repository on how to set it up. The atlas generation step can easily be integrated into the build bat / sh files such as build_hot_reload.sh