Raylib Hot Reload in Go
A proof of concept of using hot reload with the raylib library in Go.
Overview
This project demonstrates a hot-reloading mechanism for game development in Go, leveraging Raylib for graphics and Yaegi for dynamic code interpretation. This setup allows for rapid iteration by applying code changes without recompiling or restarting the application.
Prerequisites
Before running this project, ensure you have the following installed:
-
Go: Make sure you have Go installed and configured correctly. This includes having a working Go environment with either GOPATH
set up or Go modules enabled. (otherwise, yaegi extract
will fail)
-
Yaegi: Install Yaegi using the following command:
go install github.com/traefik/yaegi/cmd/yaegi@latest
To enable Yaegi to interact with Raylib, you need to extract the necessary symbols. Follow these steps:
-
Navigate to the symbols
directory:
cd symbols
-
Run the Yaegi extraction command:
yaegi extract github.com/gen2brain/raylib-go/raylib
How to Run the Project
-
Clone the repository.
-
Navigate to the project directory.
-
Run the main application:
go run .
-
Modify the src/game.go
file while the application is running. Changes will be applied dynamically.
Project Structure
main.go
: The main application file that sets up the Raylib window, the Yaegi interpreter, and the file watcher.
src/game.go
: Contains the game logic that is dynamically reloaded.
symbols/
: Contains the extracted Raylib symbols.
Inspiration
This project was inspired by Gandalf-Le-Dev/ebitengine-yaegi-hotreload, which demonstrates a similar hot-reloading approach for the Ebitengine game library.