Skip to content

ingur/raylib-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raylib-starter

My personal, minimal game template for creating cross-platform raylib games using LuaJIT (and C/C++).

Features

  • 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

Requirements

  • git, cmake, g++, zip
  • mingw-w64 for the windows target

Getting Started

Clone the repository:

git clone --depth 1 https://github.com/ingur/raylib-starter.git

Use the helper script to initialize the build files and run the game:

./build.sh run

You 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 message

Note

When adding/removing C++ source files, the build files should be re-initialized using ./build.sh init

Example Code

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()

Configuration/Tips

  • Default lua entrypoint is set to lua/main.lua
  • Basic autocompletion support is available through the lua/defs.lua file (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

Credits

About

My personal, minimal game template for creating cross-platform raylib games using LuaJIT (and C/C++).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published