My personal, minimal game template for creating cross-platform raylib games using LuaJIT (and C/C++).
- Includes pre-built LuaJIT and raylib (v5.5)
- C/C++ and LuaJIT interoperability using
ffi - Cross-platform builds (Linux-x64 & Windows-x64)
- Includes build helper script for easy development
- Configurable automatic asset packing/loading using custom zip-files
NOTE: the old C/C++ only version with basic web target support (no LuaJIT) can be found here
git,cmake,g++,zipmingw-w64for the windows target
Clone the repository:
git clone --depth 1 https://github.com/ingur/raylib-starter.gitUse the helper script to initialize the build files and run the game:
./build.sh runYou can use the following commands:
# usage: ./build.sh <command> [options]
./build.sh init # re-initalizes all build files using CMake
./build.sh linux_x86_64 # builds linux target [debug|release] [zip]
./build.sh windows_x86_64 # builds windows target [debug|release] [zip]
./build.sh all # build for all platforms and types [zip]
./build.sh run # builds and runs default target [debug|release] [zip]
./build.sh clean # cleans build environment for all targets
./build.sh help # shows the help messageNote
When adding/removing C++ source files, the build files should be re-initialized using ./build.sh init
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "basic window")
while not rl.WindowShouldClose() do
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY)
rl.EndDrawing()
end
rl.CloseWindow()- Default lua entrypoint is set to
lua/main.lua - Basic autocompletion support is available through the
lua/defs.luafile (source) - Project name / source files can be configured in
CMakeLists.txt - Asset packing format/structure can be configured in
build.sh - Assets/files can also be loaded through the virtual filesystem, e.g:
local texture = rl.LoadTexture("assets/texture.png") local library = require("library") -- looks in lua/ archive by default
- raylib for the amazing library
- raylib-lua for LuaJIT-based raylib bindings
