# ReiLua Manual

# ReiLua - Enhanced Edition

> A modified version of ReiLua with embedded main.lua, embedded assets, splash screens, and asset loading system

## About This Version

This is an enhanced version of ReiLua featuring:

- Embedded Lua Support - Bundle all your Lua code into a single executable
- Embedded Assets - Package images, sounds, and other assets into your game
- Splash Screens - Customizable startup screens featuring Raylib and ReiLua
- Asset Loading System - Loading screen with progress tracking
- Automated Build Scripts - One-command development and release builds
- Console Control - Debug logging system for development

## What is ReiLua?

ReiLua brings the power and simplicity of Raylib to the beginner-friendly Lua language in a straightforward manner. It is a loose binding to Raylib - some functions are excluded and some are added. The concept of pointing to a "main.lua" file and accessing functions "init", "update", and "draw" is borrowed from the Löve game framework.

Note: ReiLua is lovingly handcrafted and will likely contain bugs and documentation errors, so it would be much appreciated if you would report any such findings. Reilua means "fair" in Finnish.

## Attributions

This enhanced version is built upon:

### Core Framework

- Raylib (v5.5) - A simple and easy-to-use library to enjoy videogames programming
- Created by Ray(Ramon Santamaria) (@raysan5)
- Licensed under the zlib/libpng license
- ReiLua - The original Lua bindings for Raylib
- Created by Jussi Viitala
- Licensed under the MIT license
- Lua (v5.4) - Powerful, efficient, lightweight, embeddable scripting language

### Enhancements Added

- Embedded Lua and asset support system
- Splash screen implementation
- Asset loading progress API with retro UI
- Build automation scripts
- Console control system
- Comprehensive documentation

### Additional Components

- Raygui - Immediate mode GUI library
- Raymath - Math utilities for game development
- Lights - 3D lighting system
- Easings - Easing functions for smooth animations
- RLGL - OpenGL abstraction layer

### Font

- Oleaguid - Custom pixel art font for splash and loading screens

## Status

ReiLua is WIP and some planned raylib functionality is still missing, but it already has over 1000 functions. Current Raylib version is 5.5.

### Included Submodules

- Raygui
- Raymath
- Lights
- Easings
- RLGL

### Missing Features

List of some MISSING features that are planned to be included:

- Core
- VR stereo config functions for VR simulator

## Roadmap

- v0.9
- Stability improvements
- Additional raylib bindings
- v1.0
- raylib 6.0 support

## Quick Start

### For Game Developers

Development Mode (Fast Iteration):

    # 1. Create your game files
    GameFolder/
    ├── main.lua
    ├── assets/
    │   ├── player.png
    │   └── music.wav

    # 2. Run ReiLua pointing to your game folder
    ReiLua.exe GameFolder/

    # Or from your game folder
    cd GameFolder
    path/to/ReiLua.exe

    # Skip splash screens during development
    ReiLua.exe --no-logo

    # Enable console for debugging
    ReiLua.exe --log --no-logo

Release Mode (Single Executable):

    # See "Building for Release" section below

### Basic Example

Create a `main.lua` file:

    local textColor = RL.BLACK
    local textPos = { 192, 200 }
    local textSize = 20
    local text = "Congrats! You created your first window!"

    function RL.init()
    	RL.SetWindowTitle( "First window" )
    	RL.SetWindowState( RL.FLAG_VSYNC_HINT )
    end

    function RL.update( delta )
    	if RL.IsKeyPressed( RL.KEY_ENTER ) then
    		local winSize = RL.GetScreenSize()
    		local measuredSize = RL.MeasureTextEx( RL.GetFontDefault(), text, textSize, 2 )

    		textColor = RL.BLUE
    		textPos = { winSize[1] / 2 - measuredSize[1] / 2, winSize[2] / 2 - measuredSize[2] / 2 }
    	end

    	if RL.IsKeyPressed( RL.KEY_SPACE ) then
    		textColor = RL.RED
    		textPos = { 192, 200 }
    	end
    end

    function RL.draw()
    	RL.ClearBackground( RL.RAYWHITE )
    	RL.DrawText( text, textPos, textSize, textColor )
    end

Run it:

    ReiLua.exe --no-logo

## Framework Functions

ReiLua looks for a 'main.lua' or 'main' file as the entry point. There are seven Lua functions that the framework will call:

- `RL.init()` - Called once at startup for initialization
- `RL.update(delta)` - Called every frame before draw, receives delta time
- `RL.draw()` - Called every frame for rendering
- `RL.event(event)` - Called when events occur
- `RL.log(logLevel, message)` - Called for logging
- `RL.exit()` - Called when the application is closing
- `RL.config()` - ⚠️ Deprecated in this version

All functionality can be found in "API.md".

## Enhanced Features

### 1. Splash Screens

This version includes customizable splash screens that display at startup:

Screen 1: Custom text - Bold text on Raylib red background (customizable) Screen 2: "Made using" - Displays Raylib and ReiLua logos side-by-side

Each screen fades in (0.8s), displays (2.5s), and fades out (0.8s) for a total of ~8 seconds.

Skip During Development:

    ReiLua.exe --no-logo

Customize:

- Change text in `src/splash.c`
- Replace logos in `logo/` folder
- Adjust timing with constants in `src/splash.c`

See SPLASH_SCREENS.md for full documentation.

### 2. Asset Loading System

Beautiful loading screen with progress tracking:

    function RL.init()
        -- List your assets
        local assets = {
            "assets/player.png",
            "assets/enemy.png",
            "assets/background.png",
            "assets/music.wav",
        }

        -- Start loading with progress
        RL.BeginAssetLoading(#assets)

        -- Load each asset
        for i, path in ipairs(assets) do
            RL.UpdateAssetLoading(path)

            -- Your loading code
            if path:match("%.png$") then
                textures[i] = RL.LoadTexture(path)
            elseif path:match("%.wav$") then
                sounds[i] = RL.LoadSound(path)
            end
        end

        -- Finish loading
        RL.EndAssetLoading()
    end

Features:

- Retro 1-bit pixel art aesthetic
- Animated loading text with dots
- Progress bar with dithering pattern
- Shows current asset name
- Progress counter (e.g., "3/10")
- Corner decorations

See ASSET_LOADING.md for full documentation.

### 3. Embedded Lua Files

Bundle all your Lua code into the executable for easy distribution:

    # Copy Lua files to build directory
    cd build
    copy ..\your_game\*.lua .

    # Build with embedding
    cmake .. -DEMBED_MAIN=ON
    cmake --build . --config Release

Result: Single executable with all Lua code embedded!

### 4. Embedded Assets

Package images, sounds, fonts, and other assets into your executable:

    # Create assets folder and copy files
    cd build
    mkdir assets
    copy ..\your_game\assets\* assets\

    # Build with embedding
    cmake .. -DEMBED_ASSETS=ON
    cmake --build . --config Release

Your Lua code doesn't change! Use the same paths:

    -- Works in both development and release
    playerImg = RL.LoadTexture("assets/player.png")
    music = RL.LoadSound("assets/music.wav")

See EMBEDDING.md for full documentation.

### 5. Console Control (Windows)

By default, ReiLua runs without a console window for a clean user experience. Enable it for debugging:

    # Show console for debugging
    ReiLua.exe --log

    # Combine with other options
    ReiLua.exe --log --no-logo
    ReiLua.exe --log path/to/game

This shows:

- TraceLog output
- Print statements
- Lua errors
- Debug information

### 6. Automated Build Scripts

One-command builds for development and release:

Development Build (Fast Iteration):

    # Windows
    scripts\build_dev.bat

    # Linux/Unix
    chmod +x scripts/build_dev.sh
    scripts/build_dev.sh

- No embedding
- Fast build times
- Edit code without rebuilding

Release Build (Distribution):

    # Prepare files first
    cd build
    copy ..\your_game\*.lua .
    mkdir assets
    copy ..\your_game\assets\* assets\

    # Build release
    cd ..

    # Windows
    scripts\build_release.bat

    # Linux/Unix
    scripts/build_release.sh

- Embeds all Lua files
- Embeds all assets
- Creates single executable
- Release optimizations

See BUILD_SCRIPTS.md for full documentation.

## Command Line Options

    ReiLua [Options] [Directory to main.lua or main]

    Options:
      -h, --help       Show help message
      -v, --version    Show ReiLua version
      -i, --interpret  Interpret mode [File name]
      --log            Show console window for logging (Windows only)
      --no-logo        Skip splash screens (development)

### Examples

    # Run game in current directory
    ReiLua.exe

    # Run game in specific folder
    ReiLua.exe path/to/game/

    # Development mode (no splash, with console)
    ReiLua.exe --log --no-logo

    # Interpreter mode (run single script)
    ReiLua.exe -i script.lua

    # Show help
    ReiLua.exe --help

    # Show version
    ReiLua.exe --version

## Object Unloading

Some objects allocate memory that needs to be freed when no longer needed. By default, objects like Textures are unloaded by the Lua garbage collector. However, it's generally recommended to handle this manually in more complex projects:

    RL.SetGCUnload()

## Interpreter Mode

ReiLua can run single Lua files using interpreter mode:

    ReiLua -i hello.lua

The given file will be called with `dofile`.

## Generate API Documentation

Generate API.md and ReiLua_API.lua from the build folder:

    ReiLua -i ../tools/docgen.lua

Tip: Use tools/ReiLua_API.lua in your project folder to provide annotations when using "Lua Language Server".

## Building from Source

### Prerequisites

You'll need to statically link Raylib and Lua to create the executable. This simplifies distribution, especially on Linux where different distros use different library versions.

- Raylib: https://github.com/raysan5/raylib
- Lua: https://github.com/lua/lua or https://github.com/LuaJIT/LuaJIT
- CMake: https://cmake.org/download/
- Build tools: MinGW (Windows), GCC/Make (Linux)

Note: Lua header files are from Lua 5.4.0. If using a different version, replace them.

### Windows

#### 1. Install Tools

- Download w64devkit from https://github.com/skeeto/w64devkit
- Download CMake from https://cmake.org/download/ (install with PATH environment variables set)

#### 2. Build Raylib

    # Download Raylib source
    # Run w64devkit.exe and navigate to raylib/src
    cd raylib/src
    mingw32-make

    # Copy libraylib.a to ReiLua/lib folder
    copy libraylib.a path\to\ReiLua\lib\

#### 3. Build Lua

Download Lua source from https://github.com/lua/lua

Modify Lua's makefile:

    # Change this:
    MYCFLAGS= $(LOCAL) -std=c99 -DLUA_USE_LINUX -DLUA_USE_READLINE
    # To this:
    MYCFLAGS= $(LOCAL) -std=c99

    # Comment out or remove:
    MYLIBS= -ldl -lreadline

Build:

    # In w64devkit, navigate to Lua folder
    mingw32-make

    # Copy liblua.a to ReiLua/lib folder
    copy liblua.a path\to\ReiLua\lib\

#### 4. Build ReiLua

Quick Method (Recommended):

    cd ReiLua
    scripts\build_dev.bat

Manual Method:

    cd ReiLua\build
    cmake -G "MinGW Makefiles" ..
    mingw32-make

#### 5. Test

    cd build
    ReiLua.exe ..\examples\snake\

If you see a low-res snake racing off the window, success! Press Enter to reset.

### Linux

#### 1. Install Dependencies

    sudo apt install build-essential cmake

#### 2. Build Raylib and Lua

Compile Raylib and Lua by following their instructions. They will compile to `libraylib.a` and `liblua.a` by default.

Move both `.a` files to the `ReiLua/lib` folder.

#### 3. Build ReiLua

Quick Method (Recommended):

    cd ReiLua
    chmod +x scripts/build_dev.sh
    scripts/build_dev.sh

Manual Method:

    cd ReiLua/build
    cmake ..
    make

#### 4. Test

    ./ReiLua ../examples/snake/

### MacOS

Not tested, but should work similarly to Linux.

### Raspberry Pi

Works best when Raylib is compiled using `PLATFORM=DRM`. See Raylib build instructions for Raspberry Pi.

Compile ReiLua with:

    cmake .. -DDRM=ON

Note: DRM should be launched from CLI, not in X.

### Web (Emscripten)

Compile Raylib for web following its instructions: https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)

#### 1. Compile Lua for Web

Modify Lua's makefile:

    # Change:
    MYCFLAGS= $(LOCAL) -std=c99 -DLUA_USE_LINUX -DLUA_USE_READLINE
    # To:
    MYCFLAGS= $(LOCAL) -std=c99

    # Change:
    MYLIBS= -ldl -lreadline
    # To:
    MYLIBS= -ldl

    # Change:
    CC= gcc
    # To:
    CC= emcc

    # Change:
    CFLAGS= -Wall -O2 $(MYCFLAGS) -fno-stack-protector -fno-common -march=native
    # To:
    CFLAGS= -Wall -O2 $(MYCFLAGS) -fno-stack-protector -fno-common

    # Change:
    AR= ar rc
    # To:
    AR= emar

    # Change:
    $(AR) $@ $?
    # To:
    $(AR) rcs $@ $?

Build with `make` if emsdk environmental variables are correct.

#### 2. Prepare Libraries

Put `libraylib.a` and `liblua.a` into `ReiLua/lib/web/`.

#### 3. Create Resources Folder

    cd ReiLua/build
    mkdir resources
    # Copy main.lua to resources/
    # Copy assets to resources/

Structure:

    ReiLua/
    └── build/
        └── resources/
            ├── main.lua
            └── assets/

#### 4. Build

    cd build
    cmake .. -DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DPLATFORM=Web
    make

#### 5. Test

    python -m http.server 8080

Access in browser: `localhost:8080/ReiLua.html`

## Complete Release Workflow

### Step 1: Prepare Your Game

    MyGame/
    ├── main.lua
    ├── player.lua
    ├── enemy.lua
    ├── assets/
    │   ├── player.png
    │   ├── enemy.png
    │   └── music.wav

### Step 2: Copy Files to Build Directory

    cd ReiLua/build

    # Copy all Lua files
    copy ..\MyGame\*.lua .

    # Copy assets
    mkdir assets
    copy ..\MyGame\assets\* assets\
    # Or: xcopy /E /I ..\MyGame\assets assets

### Step 3: Build Release

    cd ..
    scripts\build_release.bat
    # Or: scripts/build_release.sh on Linux

### Step 4: Test

    cd build
    ReiLua.exe --log

Verify:

- No file loading errors
- Game runs correctly
- All assets load properly

### Step 5: Distribute

    mkdir Distribution
    copy ReiLua.exe Distribution\YourGameName.exe

Your game is now a single executable ready for distribution!

## Customizing Your Executable

### Change Executable Name

Edit `CMakeLists.txt`:

    project( YourGameName )  # Change from "ReiLua"

### Add Custom Icon

Replace `icon.ico` with your own icon file, then rebuild.

### Edit Executable Properties

Edit `resources.rc`:

    VALUE "CompanyName", "Your Studio Name"
    VALUE "FileDescription", "Your Game Description"
    VALUE "ProductName", "Your Game Name"
    VALUE "LegalCopyright", "Copyright (C) Your Name, 2025"

### Customize Splash Screens

Edit `src/splash.c`:

    const char* text = "YOUR STUDIO NAME";  // Change this

Replace logos:

    # Replace these files before building
    logo/raylib_logo.png
    logo/reilua_logo.png

## Setting Up Zed Editor

Zed is a modern, high-performance code editor. Here's how to set it up for ReiLua development:

### Install Zed

Download from: https://zed.dev/

### Setup Lua Language Support

1. Open Zed 2. Press `Cmd+Shift+P` (Mac) or `Ctrl+Shift+P` (Windows/Linux) 3. Type "install language server" and select Lua 4. Zed will automatically install the Lua Language Server

### Configure for ReiLua

Create `.zed/settings.json` in your project root:

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua": {
              "runtime": {
                "version": "Lua 5.4"
              },
              "diagnostics": {
                "globals": ["RL"]
              },
              "workspace": {
                "library": ["ReiLua_API.lua"]
              }
            }
          }
        }
      },
      "languages": {
        "Lua": {
          "format_on_save": "on",
          "formatter": "language_server"
        }
      }
    }

### Copy ReiLua API Definitions

Copy `tools/ReiLua_API.lua` to your project folder. This provides autocomplete and documentation for all ReiLua functions.

    copy path\to\ReiLua\tools\ReiLua_API.lua your_game\

### Keyboard Shortcuts

Useful Zed shortcuts for Lua development:

- `Ctrl+P` / `Cmd+P` - Quick file search
- `Ctrl+Shift+F` / `Cmd+Shift+F` - Search in files
- `Ctrl+.` / `Cmd+.` - Code actions
- `F12` - Go to definition
- `Shift+F12` - Find references
- `Ctrl+Space` - Trigger autocomplete

### Extensions

Install useful extensions: 1. Press `Ctrl+Shift+X` / `Cmd+Shift+X` 2. Search and install:

- Lua - Syntax highlighting and language support
- Better Comments - Enhanced comment highlighting
- Error Lens - Inline error display

### Workspace Setup

Create a workspace for ReiLua projects:

1. Open your game folder in Zed 2. File → Add Folder to Workspace 3. Add the ReiLua source folder (for reference) 4. File → Save Workspace As...

This lets you easily reference ReiLua source while developing your game.

### Debugging

For debugging Lua code with Zed:

1. Use `print()` statements liberally 2. Run ReiLua with `--log` flag to see output 3. Use `RL.TraceLog()` for more detailed logging:

    RL.TraceLog(RL.LOG_INFO, "Player position: " .. x .. ", " .. y)
    RL.TraceLog(RL.LOG_WARNING, "Low health!")
    RL.TraceLog(RL.LOG_ERROR, "Failed to load asset!")

### Terminal Integration

Run ReiLua directly from Zed's terminal:

1. Press ``Ctrl+` ``/` `Cmd+` ``to open terminal 2. Run your game:`

    path\to\ReiLua.exe --log --no-logo

### Tips for ReiLua Development in Zed

1. Use Multiple Cursors: Alt+Click`to add cursors, great for batch edits 2. Split Views:` Ctrl+\`to split editor for side-by-side editing 3. Symbol Search:` Ctrl+T`/` Cmd+T`to search for functions 4. Zen Mode:` Ctrl+K Z`for distraction-free coding 5. Live Grep:` Ctrl+Shift+F`to search across all files`

## Documentation

### Comprehensive Guides

- EMBEDDING.md - Complete guide to embedding Lua and assets
- ASSET_LOADING.md - Asset loading API and loading screen documentation
- SPLASH_SCREENS.md - Splash screen customization guide
- BUILD_SCRIPTS.md - Build scripts documentation
- API.md - Complete API reference (1000+ functions)
- UPGRADE_SUMMARY.md - Technical details of enhancements

### Quick References

- docs/API.md - All ReiLua/Raylib functions
- tools/ReiLua_API.lua - Lua annotations for IDE autocomplete
- examples/ - Example games and demos

## Troubleshooting

### Common Issues

Game doesn't start:

- Run with --log`to see error messages`
- Check that main.lua`exists`
- Verify all required assets exist

Assets not loading:

- Check file paths (use forward slashes or escaped backslashes)
- Verify files exist in the correct location
- Use --log`to see loading errors`

Splash screens don't show:

- Check you're not using --no-logo`flag`
- Verify build completed successfully
- Rebuild project: cmake --build . --config Release``

Lua files not embedded:

- Ensure Lua files are in build/`directory before building`
- Check main.lua`exists`
- Verify -DEMBED_MAIN=ON`was used`

Assets not embedded:

- Create build/assets/`folder`
- Copy assets before building
- Verify -DEMBED_ASSETS=ON`was used`

Build fails:

- Check CMake and compiler are installed and in PATH
- Verify libraylib.a`and` liblua.a`are in` lib/`folder`
- Try clean build: scripts\build_dev.bat clean``

### Getting Help

1. Check documentation files listed above 2. Review the examples in examples/`folder 3. Use` --log` flag to see detailed error messages 4. Check your file paths and directory structure

## Contributing

Contributions are welcome! This is an enhanced version with additional features. When contributing:

1. Test thoroughly with both development and release builds 2. Update documentation if adding features 3. Follow existing code style 4. Test on multiple platforms if possible

## License

ReiLua is licensed under the zlib/libpng license. See LICENSE file for details.

### Third-Party Licenses

- Raylib - zlib/libpng license
- Lua - MIT license
- Oleaguid Font - Check font documentation for licensing

## Contact & Links

- Original ReiLua: https://github.com/Gamerfiend/ReiLua
- Raylib: https://github.com/raysan5/raylib
- Lua: https://www.lua.org/

## Version Information

- ReiLua Version: Based on original ReiLua with enhancements
- Raylib Version: 5.5
- Lua Version: 5.4

---

Happy Game Development!

## Embedding

# Embedding main.lua into Executable

When you're ready to ship your game, you can embed all Lua files and asset files directly into the executable.

## Development vs Release Workflow

Development Build (Fast Iteration)

During development, use external files for quick iteration.

Setup:

    GameFolder/
    ├── ReiLua.exe
    ├── main.lua
    ├── player.lua
    └── assets/
        ├── player.png
        └── music.wav

Build:

    cd build
    cmake ..
    cmake --build .

Benefits:

- Edit Lua files and re-run immediately
- Edit assets and reload
- Fast development cycle
- Debug with `--log` flag

Release Build (Single Executable)

For distribution, embed everything into one file.

Setup:

    cd build

    # Copy Lua files to build directory
    copy ..\main.lua .
    copy ..\player.lua .

    # Create assets folder and copy files
    mkdir assets
    copy ..\player.png assets\
    copy ..\music.wav assets\

Build:

    # Configure with embedding
    cmake .. -DEMBED_MAIN=ON -DEMBED_ASSETS=ON

    # Build release
    cmake --build . --config Release

Result:

    Distribution/
    └── YourGame.exe  (Everything embedded!)

Benefits:

- Single executable file
- No external dependencies
- Users can't modify game files
- Smaller download (no separate files)

## Quick Start

### Embedding Lua Files

1. Copy your Lua files to the build directory:

       copy main.lua build\main.lua
       copy player.lua build\player.lua

2. Build with EMBED_MAIN option:

       cd build
       cmake .. -DEMBED_MAIN=ON
       cmake --build . --config Release

## Command Line Options

ReiLua supports several command-line options:

    ReiLua [Options] [Directory to main.lua or main]

    Options:
      -h, --help       Show help message
      -v, --version    Show ReiLua version
      -i, --interpret  Interpret mode [File name]
      --log            Show console window for logging (Windows only)

### Console/Logging

By default, ReiLua runs without a console window for a clean user experience. To enable console output for debugging:

    # Run with console for debugging
    ReiLua.exe --log

    # You can also combine with other options
    ReiLua.exe --log path/to/game

    # Or with interpret mode
    ReiLua.exe --log -i script.lua

This is useful during development to see:

- TraceLog output
- Print statements
- Lua errors
- Debug information

## Complete Release Workflow

Here's a complete step-by-step guide to prepare your game for release:

### Step 1: Organize Your Project

Ensure your project has this structure:

    MyGame/
    ├── main.lua
    ├── player.lua
    ├── enemy.lua
    ├── player.png
    ├── enemy.png
    ├── music.wav
    └── icon.ico (optional)

### Step 2: Customize Branding (Optional)

Change executable icon:

    # Replace ReiLua's icon with yours
    copy MyGame\icon.ico ReiLua\icon.ico

Edit executable properties: Open `ReiLua\resources.rc` and modify:

    VALUE "CompanyName", "Your Studio Name"
    VALUE "FileDescription", "Your Game Description"
    VALUE "ProductName", "Your Game Name"
    VALUE "LegalCopyright", "Copyright (C) Your Name, 2025"

Change executable name: Edit `ReiLua\CMakeLists.txt`:

    project( YourGameName )  # Change from "ReiLua"

See CUSTOMIZATION.md for full details.

### Important: Asset Paths

Keep your paths consistent! The embedding system now preserves the `assets/` prefix, so use the same paths in both development and release:

    --  Correct - works in both dev and release
    playerImage = RL.LoadTexture("assets/player.png")
    backgroundImg = RL.LoadTexture("assets/background.png")
    musicSound = RL.LoadSound("assets/music.wav")

Your Lua code doesn't need to change between development and release builds!

### Step 3: Prepare Build Directory

    cd ReiLua\build

    # Copy all Lua files
    copy ..\MyGame\*.lua .

    # Create assets folder
    mkdir assets

    # Copy all asset files (images, sounds, etc.)
    copy ..\MyGame\*.png assets\
    copy ..\MyGame\*.wav assets\
    copy ..\MyGame\*.ogg assets\
    # Or copy entire folders
    xcopy /E /I ..\MyGame\images assets\images
    xcopy /E /I ..\MyGame\sounds assets\sounds

### Step 4: Build Release

    # Configure with embedding enabled
    cmake .. -DEMBED_MAIN=ON -DEMBED_ASSETS=ON

    # Build in release mode
    cmake --build . --config Release

### Step 5: Test Release Build

    # Test with console to verify everything loaded
    YourGameName.exe --log

    # Test production mode (no console)
    YourGameName.exe

Check console output for:

- "ReiLua x.x.x" version info
- No file loading errors
- Game runs correctly

### Step 6: Package for Distribution

    # Create distribution folder
    mkdir ..\Distribution
    copy YourGameName.exe ..\Distribution\

    # Optional: Add README, LICENSE, etc.
    copy ..\README.txt ..\Distribution\

Your game is now ready to distribute as a single executable!

### Workflow Summary

| Stage | Build Command | Files Needed | Result | |-------|--------------|--------------|--------| | Development | `cmake .. && cmake --build .` | Lua + assets external | Fast iteration | | Testing | `cmake .. -DEMBED_MAIN=ON && cmake --build .` | Lua in build/ | Test embedding | | Release | `cmake .. -DEMBED_MAIN=ON -DEMBED_ASSETS=ON && cmake --build . --config Release` | Lua + assets in build/ | Single .exe |

### Troubleshooting

Problem: "No .lua files found in build directory"

    # Solution: Copy Lua files to build directory
    copy ..\*.lua .

Problem: "No files found in assets folder"

    # Solution: Create assets folder and copy files
    mkdir assets
    copy ..\*.png assets\

Problem: Game crashes on startup

    # Solution: Run with --log to see error messages
    YourGameName.exe --log

Problem: Assets not loading

- Verify assets are in `build/assets/` before building
- Check asset filenames match in your Lua code
- Use `--log` to see loading errors

### Notes

- `.lua` files in the build directory root are embedded when using `EMBED_MAIN=ON`
- Asset files in build/assets/ folder (and subfolders) are embedded when using `EMBED_ASSETS=ON`
- `main.lua` must exist and is always the entry point
- Asset embedding works with subdirectories: `assets/images/player.png` → Load with `LoadImage("player.png")`
- Both Lua and asset embedding can be used independently or together
- The system falls back to file system if embedded file is not found
- No code changes needed - all raylib functions work automatically with embedded assets

## Customizing Your Executable

Want to add your own icon and version info to the executable? See CUSTOMIZATION.md for details on:

- Adding a custom icon
- Setting exe properties (company name, version, description)
- Renaming the executable

## Asset Loading

# Asset Loading System

ReiLua includes a built-in asset loading system with a loading screen UI that shows progress while assets are being loaded.

## Features

- Automatic Progress Tracking - Tracks how many assets have been loaded
- Loading UI with:
- Animated "Loading..." text with dots
- Smooth progress bar with shimmer effect
- Progress percentage (e.g., "3 / 10")
- Current asset name being loaded
- Easy to Use - Just 3 functions to show loading progress
- Works in development and release builds

## API Functions

### RL.BeginAssetLoading(totalAssets)

Initialize asset loading progress tracking and show the loading screen.

Parameters:

- `totalAssets` (integer) - Total number of assets to load

Example:

    RL.BeginAssetLoading(10)  -- We're loading 10 assets

---

### RL.UpdateAssetLoading(assetName)

Update the loading progress and display current asset being loaded.

Parameters:

- `assetName` (string) - Name of the asset currently being loaded

Example:

    RL.UpdateAssetLoading("player.png")

Call this after each asset is loaded to update the progress bar.

---

### RL.EndAssetLoading()

Finish asset loading and hide the loading screen.

Example:

    RL.EndAssetLoading()

## Quick Example

    function RL.init()
        -- List of assets to load
        local assetsToLoad = {
            "assets/player.png",
            "assets/enemy.png",
            "assets/background.png",
            "assets/music.wav",
        }

        -- Begin loading
        RL.BeginAssetLoading(#assetsToLoad)

        -- Load each asset
        for i, path in ipairs(assetsToLoad) do
            RL.UpdateAssetLoading(path)  -- Update progress

            -- Load the actual asset
            if path:match("%.png$") or path:match("%.jpg$") then
                textures[i] = RL.LoadTexture(path)
            elseif path:match("%.wav$") or path:match("%.ogg$") then
                sounds[i] = RL.LoadSound(path)
            end
        end

        -- Done!
        RL.EndAssetLoading()
    end

## Complete Example

    local assets = {}

    local assetsToLoad = {
        {type="texture", name="player", path="assets/player.png"},
        {type="texture", name="enemy", path="assets/enemy.png"},
        {type="texture", name="background", path="assets/background.png"},
        {type="sound", name="music", path="assets/music.wav"},
        {type="sound", name="shoot", path="assets/shoot.wav"},
        {type="font", name="title", path="assets/title.ttf"},
    }

    function RL.init()
        RL.SetWindowTitle("My Game")

        -- Start loading with progress
        RL.BeginAssetLoading(#assetsToLoad)

        -- Load all assets
        for i, asset in ipairs(assetsToLoad) do
            -- Show current asset name on loading screen
            RL.UpdateAssetLoading(asset.name)

            -- Load based on type
            if asset.type == "texture" then
                assets[asset.name] = RL.LoadTexture(asset.path)
            elseif asset.type == "sound" then
                assets[asset.name] = RL.LoadSound(asset.path)
            elseif asset.type == "font" then
                assets[asset.name] = RL.LoadFont(asset.path)
            end
        end

        -- Loading complete!
        RL.EndAssetLoading()

        print("Game ready!")
    end

    function RL.update(delta)
        -- Your game logic
    end

    function RL.draw()
        RL.ClearBackground(RL.RAYWHITE)

        -- Use loaded assets
        if assets.background then
            RL.DrawTexture(assets.background, {0, 0}, RL.WHITE)
        end

        if assets.player then
            RL.DrawTexture(assets.player, {100, 100}, RL.WHITE)
        end
    end

## Loading Screen Appearance

The loading screen features a clean 1-bit pixel art style:

Design:

- Pure black and white aesthetic
- Retro pixel art styling
- Minimal and clean design

Elements:

- Title: "LOADING" in bold white pixel text
- Animated Dots: White pixelated dots (4x4 squares) that cycle
- Progress Bar:
- 200px wide, 16px tall
- Thick 2px white border (pixel art style)
- White fill with black dithering pattern
- Retro/Classic terminal aesthetic
- Progress Text: "3/10" in white pixel font style
- Asset Name: Current loading asset in small white text
- Corner Decorations: White pixel art L-shaped corners in all 4 corners

Background:

- Pure black background (#000000)
- High contrast for maximum clarity

Color Palette:

- White text and UI (#FFFFFF)
- Black background (#000000)
- Pure 1-bit aesthetic (inverted terminal style)

Style Inspiration:

- Classic terminal / console aesthetic
- MS-DOS loading screens
- 1-bit dithering patterns
- Chunky pixel borders
- Retro computing / CRT monitor style

## Customization

If you want to customize the loading screen appearance, you can modify the colors and sizes in `src/lua_core.c` in the `drawLoadingScreen()` function.

## Performance Tips

1. Call UpdateAssetLoading AFTER loading - This ensures the progress updates at the right time 2. Load assets in order of importance - Load critical assets first 3. Group similar assets - Load all textures, then sounds, etc. 4. Use descriptive names - Shows better feedback to users

## Example Asset Loading Patterns

### Pattern 1: Simple List

    local files = {"player.png", "enemy.png", "music.wav"}
    RL.BeginAssetLoading(#files)
    for i, file in ipairs(files) do
        RL.UpdateAssetLoading(file)
        -- load file
    end
    RL.EndAssetLoading()

### Pattern 2: With Types

    local assets = {
        textures = {"player.png", "enemy.png"},
        sounds = {"music.wav", "shoot.wav"},
    }
    local total = #assets.textures + #assets.sounds

    RL.BeginAssetLoading(total)
    for _, file in ipairs(assets.textures) do
        RL.UpdateAssetLoading(file)
        -- load texture
    end
    for _, file in ipairs(assets.sounds) do
        RL.UpdateAssetLoading(file)
        -- load sound
    end
    RL.EndAssetLoading()

### Pattern 3: Error Handling

    RL.BeginAssetLoading(#files)
    for i, file in ipairs(files) do
        RL.UpdateAssetLoading(file)

        if RL.FileExists(file) then
            -- load file
        else
            print("Warning: " .. file .. " not found")
        end
    end
    RL.EndAssetLoading()

## When to Use

Use the loading system when:

- You have more than 5-10 assets to load
- Assets are large (images, sounds, fonts)
- Loading might take more than 1 second
- You want polished loading feedback

You can skip it when:

- You have very few, small assets
- Loading is nearly instant
- You prefer immediate game start

## ✨ Benefits

- Polished user experience
- User knows the game is loading, not frozen
- Shows progress for large asset sets
- Works with embedded assets
- Minimal code required
- Beautiful default UI

The loading system makes your game feel polished with just a few lines of code!

## Splash Screens

ReiLua includes a built-in splash screen system that displays splash screens before your game loads. This gives your game a polished appearance right from startup.

## Overview

When you run your ReiLua game, it automatically shows two splash screens in sequence:

1. Custom Text - Clean, bold text on Raylib red background (similar to Squid Game style) 2. "Made using" - Text with Raylib and ReiLua logos displayed side-by-side

Each splash screen:

- Fades in over 0.8 seconds
- Displays for 2.5 seconds
- Fades out over 0.8 seconds
- Total display time: 8.2 seconds for both screens

## Features

### Always Embedded

The logo images are always embedded into the executable in both development and release builds. This means:

- No external logo files needed
- Consistent splash screens across all builds
- No risk of missing logo files
- Clean appearance from the start

### Asset Loading Integration

The splash screens display before your game's asset loading begins. This means:

1. User starts your game 2. Splash screens play (~8 seconds) 3. Your `RL.init()` function runs 4. Asset loading with progress indicator (if you use it) 5. Your game starts

This creates a smooth, polished startup experience.

## Skipping Splash Screens (Development)

During development, you often need to test your game repeatedly. Waiting for splash screens every time can slow down your workflow. Use the `--no-logo` flag to skip them:

    # Windows
    ReiLua.exe --no-logo

    # Linux/Mac
    ./ReiLua --no-logo

    # With other options
    ReiLua.exe --log --no-logo
    ./ReiLua --no-logo path/to/game/

Note: The `--no-logo` flag only works in development. In release builds, users should see the full splash screen sequence.

## Technical Details

### How It Works

The splash screen system is implemented in C and runs before any Lua code executes:

1. Logo Embedding: During build, `scripts/embed_logo.py` converts PNG files to C byte arrays 2. Initialization: Before calling `RL.init()`, the engine initializes splash screens 3. Display Loop: A dedicated loop handles timing, fading, and rendering 4. Cleanup: After completion, resources are freed and Lua code begins

### Files

- `src/splash.c` - Splash screen implementation
- `include/splash.h` - Header file
- `scripts/embed_logo.py` - Python script to embed logo images
- `logo/raylib_logo.png` - Raylib logo (embedded)
- `logo/reilua_logo.png` - ReiLua logo (embedded)

### Build Integration

The CMakeLists.txt automatically:

1. Runs `scripts/embed_logo.py` during build 2. Generates `embedded_logo.h` with logo data 3. Defines `EMBED_LOGO` flag 4. Compiles `splash.c` with the project

No manual steps required - it just works!

## Customization

### Changing Splash Screen Text

To change the default text to your studio name:

1. Open `src/splash.c` 2. Find the splash drawing function 3. Change the text line:

       const char* text = "YOUR STUDIO NAME";

4. Rebuild the project

Note: Use ALL CAPS for the Squid Game-style aesthetic.

### Changing Logos

To use different logos:

1. Replace `logo/raylib_logo.png` and/or `logo/reilua_logo.png` with your images 2. Recommended size: 256x256 or smaller (logos are auto-scaled to max 200px) 3. Format: PNG with transparency support 4. Rebuild the project - logos will be automatically embedded

### Changing Timing

To adjust how long each screen displays:

1. Open `src/splash.c` 2. Modify these constants at the top:

       #define FADE_IN_TIME 0.8f    // Seconds to fade in
       #define DISPLAY_TIME 2.5f    // Seconds to display fully
       #define FADE_OUT_TIME 0.8f   // Seconds to fade out

3. Rebuild the project

### Removing Splash Screens Entirely

If you don't want any splash screens:

1. Open `src/main.c` 2. Find this block:

       /* Show splash screens if not skipped */
       if ( !skip_splash ) {
           splashInit();
           // ... splash code ...
           splashCleanup();
       }

3. Comment out or remove the entire block 4. Rebuild the project

## Example: Complete Startup Sequence

Here's what a typical game startup looks like with everything enabled:

    ReiLua.exe MyGame/

User Experience: 1. Splash Screen 1 (4.1 seconds)

- Custom text displayed in bold (default: "YOUR STUDIO NAME")
- Red background (Raylib color #E62937)
- Subtle zoom effect

2. Splash Screen 2 (4.1 seconds)

- "Made using" text at top
- Raylib + ReiLua logos side-by-side (max 200px each)
- Black background

3. Asset Loading (varies)

- Your loading screen with progress bar
- Shows "Loading texture1.png", "3/10", etc.

4. Game Start

- Your game's main screen appears
- Player can interact

## Best Practices

1. Keep --no-logo for Development: Always use `--no-logo` during active development 2. Test Without Flag: Occasionally test without `--no-logo` to ensure splash screens work 3. Customize for Your Studio: Change the text and logos to match your branding 4. Consider Total Time: Splash (~8s) + Loading (varies) = Total startup time 5. Optimize Loading: Keep asset loading fast to maintain a good first impression

## Troubleshooting

### Splash Screens Don't Show

Problem: Game starts immediately without splash screens Solutions:

- Check you're not using `--no-logo` flag
- Verify logos exist in `logo/` folder before building
- Check console output for embedding errors
- Rebuild project completely: `cmake .. && make clean && make`

### Logos Appear Corrupted

Problem: Logos display incorrectly or not at all Solutions:

- Verify PNG files are valid (open in image viewer)
- Check file sizes aren't too large (keep under 1MB each)
- Ensure PNGs use standard format (not progressive or exotic encoding)
- Rebuild project to regenerate embedded data

### Compilation Errors

Problem: Build fails with logo-related errors Solutions:

- Ensure Python 3 is installed and in PATH
- Check `scripts/embed_logo.py` has correct paths
- Verify `logo/` folder exists with both PNG files
- Check CMake output for specific error messages

## Command Reference

    # Development (skip splash)
    ReiLua --no-logo

    # Development with logging
    ReiLua --log --no-logo

    # Production/testing (full splash)
    ReiLua

    # Help
    ReiLua --help

---

The splash screen system adds a polished touch to your ReiLua games with minimal effort. Customize it to match your studio's branding and give players a great first impression!

## Build Scripts

# Build Scripts Documentation

ReiLua includes automated build scripts for easy development and release builds.

## Available Scripts

### Development Build Scripts

- Windows: `scripts\build_dev.bat`
- Linux/Unix: `scripts/build_dev.sh`

### Release Build Scripts

- Windows: `scripts\build_release.bat`
- Linux/Unix: `scripts/build_release.sh`

## Development Build

### Purpose

Fast iteration during game development with external Lua files and assets.

### Usage

Windows:

    scripts\build_dev.bat

Linux/Unix:

    chmod +x scripts/build_dev.sh
    scripts/build_dev.sh

### Features

- No embedding - loads Lua and assets from file system
- Fast build times
- Edit code and assets without rebuilding
- Automatic cleanup of embedded files
- Warns if Lua files or assets are in build directory
- Optional clean build: `scripts\build_dev.bat clean` or `scripts/build_dev.sh clean`

### Output

- Development executable: `build/ReiLua.exe`
- Run your game: `cd your_game && path/to/build/ReiLua.exe`
- Debug mode: `path/to/build/ReiLua.exe --log`

## Release Build

### Purpose

Create a single-file executable for distribution with all code and assets embedded.

### Preparation

Before running the release build, prepare your files:

    cd build

    # Copy all Lua files
    copy ..\your_game\*.lua .
    # Or: cp ../your_game/*.lua .

    # Copy assets
    mkdir assets
    copy ..\your_game\assets\* assets\
    # Or: cp -r ../your_game/assets/* assets/

### Usage

Windows:

    scripts\build_release.bat

Linux/Unix:

    chmod +x scripts/build_release.sh
    scripts/build_release.sh

### Features

- Embeds all Lua files from `build/` directory
- Embeds all assets from `build/assets/` folder
- Creates single-file executable
- Release optimization enabled
- Verifies Lua files and assets before building
- Shows summary of embedded files after build
- Interactive confirmation before building

### Output

- Release executable: `build/ReiLua.exe`
- Ready for distribution - no external dependencies
- Can be renamed to your game name

### Build Configuration

The release build automatically configures:

- `EMBED_MAIN=ON` - Embeds all Lua files
- `EMBED_ASSETS=ON` - Embeds all assets (if assets folder exists)
- `CMAKE_BUILD_TYPE=Release` - Optimized build

## Customizing Your Executable

### Adding Custom Icon

1. Replace `icon.ico` with your own icon file 2. Keep the same filename or update `resources.rc` 3. Rebuild

### Changing Executable Properties

Edit `resources.rc` to customize:

    VALUE "CompanyName", "Your Studio Name"
    VALUE "FileDescription", "Your Game Description"
    VALUE "ProductName", "Your Game Name"
    VALUE "LegalCopyright", "Copyright (C) Your Name, 2025"

### Renaming the Executable

Edit `CMakeLists.txt`:

    project( YourGameName )  # Line 6

After building, the executable will be named `YourGameName.exe`.

## Workflow Examples

### Development Workflow

    # Initial setup
    scripts\build_dev.bat

    # Edit your Lua files in your game directory
    # ... make changes ...

    # Just run - no rebuild needed!
    cd your_game
    path\to\build\ReiLua.exe

    # If you modify C code, rebuild
    scripts\build_dev.bat

### Release Workflow

    # 1. Prepare files
    cd build
    copy ..\your_game\*.lua .
    mkdir assets
    copy ..\your_game\assets\* assets\

    # 2. Build release
    cd ..
    scripts\build_release.bat

    # 3. Test
    cd build
    ReiLua.exe --log

    # 4. Distribute
    # Copy build\ReiLua.exe to your distribution folder

## Troubleshooting

### "CMake configuration failed"

- Ensure CMake is installed and in PATH
- Ensure MinGW is installed and in PATH
- Check `CMakeLists.txt` exists in parent directory

### "No Lua files found"

- Copy your Lua files to `build/` directory before release build
- Ensure `main.lua` exists (required entry point)

### "Build failed"

- Check compiler errors in output
- Ensure all dependencies are installed
- Try clean build: `scripts\build_dev.bat clean`

### Development build embedding warning

- The dev build script warns if it finds Lua files or assets in build/
- These should be removed for development builds
- The script offers to remove them automatically

## Script Features

### Safety Features

- Checks for correct directory before running
- Validates required files exist
- Warns about potential issues
- Interactive confirmations for release builds
- Automatic cleanup of old embedded files

### User Friendly

- Clear progress messages
- Colored output (where supported)
- Helpful error messages
- Pause at end to review results
- Quick reference commands shown after build

## Notes

- Development builds are much faster than release builds
- Release builds may take longer due to embedding and optimization
- Always test your release build before distribution
- The scripts work on both Windows (CMD/PowerShell) and Unix shells
- On Unix, make scripts executable: `chmod +x build_*.sh`

## Customization

# Customizing Your ReiLua Executable

This guide explains how to customize the ReiLua executable with your own branding.

## Overview

You can customize:

- Executable name
- Window icon
- File properties (company name, version, description, etc.)
- Splash screen text and logos
- Loading screen appearance

## Quick Customization Checklist

- [ ] Change executable name in CMakeLists.txt
- [ ] Replace icon.ico with your game icon
- [ ] Edit resources.rc with your game information
- [ ] Customize splash screens in src/splash.c
- [ ] Replace logo images in logo/ folder
- [ ] Rebuild the project

## 1. Changing the Executable Name

The easiest customization - change "ReiLua.exe" to "YourGame.exe".

### Steps

1. Open `CMakeLists.txt` 2. Find line 6 (near the top):

       project( ReiLua )

3. Change to your game name:

       project( MyAwesomeGame )

4. Rebuild:

       cd build
       cmake ..
       cmake --build . --config Release

Result: Executable is now named `MyAwesomeGame.exe`

## 2. Adding a Custom Icon

Replace the default icon with your game's icon.

### Requirements

- Format: .ico file (Windows icon format)
- Recommended sizes: 16x16, 32x32, 48x48, 256x256
- Tools: Use online converters or tools like IcoFX, GIMP, or Photoshop

### Steps

1. Create or convert your image to .ico format 2. Replace `icon.ico` in the ReiLua root folder with your icon 3. Keep the same filename (`icon.ico`) or update `resources.rc`:

       IDI_ICON1 ICON "your_icon.ico"

4. Rebuild the project

Tip: Many online tools can convert PNG to ICO:

- https://convertio.co/png-ico/
- https://www.icoconverter.com/

## 3. Customizing Executable Properties

When users right-click your .exe and select "Properties", they see file information. Customize this to show your game details.

### Steps

1. Open `resources.rc` 2. Find the `VERSIONINFO` section 3. Modify these values:

    1 VERSIONINFO
    FILEVERSION     1,0,0,0      // Change version numbers
    PRODUCTVERSION  1,0,0,0      // Change product version
    FILEFLAGSMASK   0x3fL
    FILEFLAGS       0x0L
    FILEOS          VOS_NT_WINDOWS32
    FILETYPE        VFT_APP
    FILESUBTYPE     VFT2_UNKNOWN
    BEGIN
        BLOCK "StringFileInfo"
        BEGIN
            BLOCK "040904b0"
            BEGIN
                VALUE "CompanyName",      "Your Studio Name"           // Your company/studio
                VALUE "FileDescription",  "Your Game - An awesome game"  // Game description
                VALUE "FileVersion",      "1.0.0.0"                    // File version string
                VALUE "InternalName",     "YourGame"                   // Internal name
                VALUE "LegalCopyright",   "Copyright (C) 2025 Your Name"  // Copyright notice
                VALUE "OriginalFilename", "YourGame.exe"               // Original filename
                VALUE "ProductName",      "Your Game"                  // Product name
                VALUE "ProductVersion",   "1.0.0.0"                    // Product version string
            END
        END
        BLOCK "VarFileInfo"
        BEGIN
            VALUE "Translation", 0x409, 1200
        END
    END

### Common Values

FileVersion / ProductVersion Format: Major, Minor, Patch, Build

- Example: `1,0,0,0` for version 1.0.0.0
- Example: `2,3,1,5` for version 2.3.1.5

CompanyName Examples:

- "Your Studio Name"
- "Independent Developer"
- "Your Name Games"

FileDescription:

- Short description users see in file properties
- Example: "Space Adventure Game"
- Example: "Puzzle Game with Physics"

LegalCopyright:

- Standard format: "Copyright (C) Year Your Name"
- Example: "Copyright (C) 2025 Indie Studios"

4. Rebuild the project

## 4. Customizing Splash Screens

Change the text and logos that appear when your game starts.

### Changing Splash Screen Text

1. Open `src/splash.c` 2. Find the splash drawing function (around line 150) 3. Change this line:

       const char* text = "YOUR STUDIO NAME";

Style Tips:

- Use ALL CAPS for bold impact
- Keep it short (under 30 characters)
- Examples: "INDIE STUDIO GAMES", "MADE BY YOUR NAME", "GAME JAM 2025"

### Changing Splash Screen Logos

1. Create or find your logos:

- Recommended size: 256x256 pixels or smaller
- Format: PNG with transparency
- Style: Simple, recognizable logos work best

2. Replace these files:

       logo/raylib_logo.png  → Your game logo
       logo/reilua_logo.png  → Your studio logo (or keep ReiLua logo as credit)

3. Logo sizing:

- Logos are automatically scaled to max 200px
- They display side-by-side on second splash screen
- Maintain aspect ratio

4. Rebuild the project - logos are automatically embedded

### Changing Splash Screen Timing

1. Open `src/splash.c` 2. Modify these constants at the top:

       #define FADE_IN_TIME 0.8f    // Seconds to fade in (default: 0.8)
       #define DISPLAY_TIME 2.5f    // Seconds fully visible (default: 2.5)
       #define FADE_OUT_TIME 0.8f   // Seconds to fade out (default: 0.8)

Recommendations:

- Keep fade times between 0.5 - 1.5 seconds
- Display time between 1.5 - 3.5 seconds
- Total splash time ideally under 10 seconds

### Changing Splash Screen Colors

1. Open `src/splash.c` 2. Find color definitions:

       // First splash screen background (Raylib red)
       Color bgColor = (Color){ 230, 41, 55, 255 };  // Change these RGB values

       // Second splash screen background (Black)
       Color bg = BLACK;  // Change to any color

Color Examples:

- White: `(Color){ 255, 255, 255, 255 }`
- Blue: `(Color){ 0, 120, 215, 255 }`
- Dark Gray: `(Color){ 32, 32, 32, 255 }`
- Your brand color: `(Color){ R, G, B, 255 }`

## 5. Customizing the Loading Screen

Change the appearance of the asset loading screen.

### Steps

1. Open `src/lua_core.c` 2. Find the `drawLoadingScreen()` function 3. Modify colors and style:

    // Background color
    Color bgColor = BLACK;  // Change background

    // Text color
    Color textColor = WHITE;  // Change text color

    // Progress bar fill color
    Color fillColor = WHITE;  // Change bar fill

    // Border color
    Color borderColor = WHITE;  // Change borders

### Customizing Loading Text

    // In drawLoadingScreen() function
    const char* loadingText = "LOADING";  // Change to "LOADING GAME", etc.

### Changing Progress Bar Size

    int barWidth = 200;   // Default 200px, change as needed
    int barHeight = 16;   // Default 16px, change as needed
    int borderThick = 2;  // Border thickness

## 6. Complete Rebranding Example

Here's a complete example of rebranding ReiLua as "Space Quest":

### 1. CMakeLists.txt

    project( SpaceQuest )

### 2. resources.rc

    VALUE "CompanyName",      "Cosmic Games Studio"
    VALUE "FileDescription",  "Space Quest - Explore the Galaxy"
    VALUE "FileVersion",      "1.0.0.0"
    VALUE "InternalName",     "SpaceQuest"
    VALUE "LegalCopyright",   "Copyright (C) 2025 Cosmic Games"
    VALUE "OriginalFilename", "SpaceQuest.exe"
    VALUE "ProductName",      "Space Quest"
    VALUE "ProductVersion",   "1.0.0.0"

### 3. icon.ico

Replace with your space-themed icon

### 4. src/splash.c

    const char* text = "COSMIC GAMES STUDIO";

### 5. logo/ folder

    logo/raylib_logo.png  → Your game logo (space ship, planet, etc.)
    logo/reilua_logo.png  → Studio logo (keep ReiLua logo for credit)

### 6. Build

    cd build
    cmake ..
    cmake --build . --config Release

Result: `SpaceQuest.exe` with all your custom branding!

## 7. Advanced: Removing ReiLua Branding

If you want to completely remove ReiLua references:

### Remove "Made with ReiLua" Logo

1. Open `src/splash.c` 2. Find `drawMadeWithSplash()` function 3. Comment out or modify the function to only show your logo

### Remove Second Splash Screen

1. Open `src/main.c` 2. Find the splash screen loop 3. Modify to only call your custom splash

Note: Please keep attribution to Raylib and ReiLua in your game's credits or about screen as a courtesy!

## 8. Build and Test

After making any customizations:

    # Clean build (recommended after customizations)
    cd build
    rm -rf *  # Or: rmdir /s /q * on Windows
    cmake ..
    cmake --build . --config Release

    # Test with console
    YourGame.exe --log

    # Test production mode
    YourGame.exe

Verify:

- Executable has correct name
- Icon appears in file explorer
- Right-click → Properties shows correct info
- Splash screens display correctly
- Loading screen appears as expected

## Checklist: Release-Ready Customization

Before releasing your game:

- [ ] Executable name matches your game
- [ ] Custom icon is recognizable at small sizes
- [ ] File properties are complete and accurate
- [ ] Splash screens show correct studio name
- [ ] Logos are high quality and appropriate size
- [ ] Loading screen matches your game's aesthetic
- [ ] Copyright and legal information is correct
- [ ] Version numbers are accurate
- [ ] Tested on target platforms
- [ ] Credits mention Raylib and ReiLua

## Tips for Polish

1. Consistent Branding: Use the same colors, fonts, and style across splash screens, loading screen, and in-game UI

2. Icon Quality: Invest time in a good icon - it's the first thing users see

3. Version Management: Update version numbers for each release

4. Legal Info: Always include proper copyright and attribution

5. Test Everything: Test your branded executable on a clean system

6. Keep Credits: Mention Raylib and ReiLua in your game's credits screen

## Troubleshooting

Icon doesn't change:

- Ensure .ico file is valid
- Rebuild completely (clean build)
- Clear icon cache (Windows): Delete `IconCache.db`

Properties don't update:

- Verify `resources.rc` syntax is correct
- Rebuild completely
- Check that resource compiler ran (check build output)

Splash screens don't show changes:

- Rebuild with clean build
- Check `scripts/embed_logo.py` ran successfully
- Verify logo files exist in `logo/` folder

Executable name unchanged:

- Check `CMakeLists.txt` project name
- Do a clean rebuild
- Verify cmake configuration step succeeded

## Additional Resources

### Icon Creation Tools

- IcoFX: Icon editor (paid)
- GIMP: Free, supports ICO export
- Online: convertio.co, icoconverter.com

### Image Editing

- GIMP: Free, powerful image editor
- Paint.NET: Simple, free Windows editor
- Photoshop: Industry standard (paid)

### Color Picking

- ColorPicker: Use system color picker
- HTML Color Codes: htmlcolorcodes.com
- Adobe Color: color.adobe.com

---

Now your ReiLua executable is fully branded and ready to represent your game!

## Editor Setup

# Zed Editor Setup for ReiLua

This guide explains how to set up autocomplete, type hints, and documentation for ReiLua in Zed Editor.

---

## Method 1: Using Lua Language Server (Recommended)

Zed uses the Lua Language Server (LuaLS) for Lua support. ReiLua includes `tools/ReiLua_API.lua` with LuaLS annotations.

### Setup Steps

#### 1. Install Lua Language Server in Zed

Zed should automatically install LuaLS when you open a Lua file. If not:

1. Open Zed 2. Go to Extensions (Cmd/Ctrl + Shift + X) 3. Search for "Lua" 4. Install the Lua extension

#### 2. Configure Your Project

Create a `.luarc.json` file in your project root:

    {
      "runtime.version": "Lua 5.4",
      "workspace.library": [
        "${3rd}/luassert/library",
        "${3rd}/busted/library"
      ],
      "completion.enable": true,
      "diagnostics.globals": [
        "RL"
      ],
      "workspace.checkThirdParty": false
    }

#### 3. Copy tools/ReiLua_API.lua to Your Project

Copy `tools/ReiLua_API.lua` to your game project folder:

    # From ReiLua directory
    cp tools/ReiLua_API.lua /path/to/your/game/project/

Or on Windows:

    Copy-Item tools/ReiLua_API.lua "C:\path\to\your\game\project\"

#### 4. (Optional) Create Library Directory

For better organization, create a library directory:

    your-game/
    ├── main.lua
    ├── .luarc.json
    └── .lua/
        └── tools/ReiLua_API.lua

Update `.luarc.json`:

    {
      "runtime.version": "Lua 5.4",
      "workspace.library": [".lua"],
      "completion.enable": true,
      "diagnostics.globals": ["RL"],
      "workspace.checkThirdParty": false
    }

---

## Method 2: Global Configuration (All Projects)

To make ReiLua API available for all projects:

### Windows

1. Create directory: `%USERPROFILE%\.luarocks\lib\lua\5.4\` 2. Copy `tools/ReiLua_API.lua` to this directory 3. Add to global LuaLS config:

Location: `%APPDATA%\Zed\settings.json` or via Zed settings

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.workspace.library": [
              "C:\\Users\\YourName\\.luarocks\\lib\\lua\\5.4"
            ],
            "Lua.diagnostics.globals": ["RL"]
          }
        }
      }
    }

### Linux/macOS

1. Create directory: `~/.lua/reilua/` 2. Copy `tools/ReiLua_API.lua` to this directory 3. Update Zed settings:

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.workspace.library": [
              "~/.lua/reilua"
            ],
            "Lua.diagnostics.globals": ["RL"]
          }
        }
      }
    }

---

## Method 3: Using Zed's LSP Configuration

Create a `.zed/settings.json` in your project: > Note There is a sample zed settings json file in the repo root (zed.sample.settings.json)

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.runtime.version": "Lua 5.4",
            "Lua.workspace.library": [
              "."
            ],
            "Lua.completion.enable": true,
            "Lua.completion.callSnippet": "Replace",
            "Lua.completion.displayContext": 3,
            "Lua.diagnostics.globals": [
              "RL"
            ],
            "Lua.hint.enable": true,
            "Lua.hint.paramName": "All",
            "Lua.hint.setType": true
          }
        }
      }
    }

---

## Verifying Setup

Create a test file `test.lua`:

    function RL.init()
        -- Type "RL." and you should see autocomplete
        RL.SetWindowTitle("Test")  -- Should show documentation

        local color = RL.RED  -- Should autocomplete color constants

        -- Hover over functions to see documentation
        RL.DrawText("Hello", 10, 10, 20, color)
    end

    function RL.update(delta)
        -- 'delta' should show as number type
    end

If autocomplete works, you should see:

- Function suggestions when typing `RL.`
- Parameter hints when calling functions
- Documentation on hover
- Constant values (RL.RED, RL.KEY_SPACE, etc.)

---

## Enhanced Features

### Enable Inlay Hints

In Zed settings:

    {
      "inlay_hints": {
        "enabled": true
      },
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.hint.enable": true,
            "Lua.hint.paramName": "All",
            "Lua.hint.setType": true,
            "Lua.hint.paramType": true
          }
        }
      }
    }

This will show:

- Parameter names inline
- Variable types
- Return types

### Disable Annoying Warnings

Add these to suppress common false positives:

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.diagnostics.disable": [
              "lowercase-global",
              "unused-local",
              "duplicate-set-field",
              "missing-fields",
              "undefined-field"
            ],
            "Lua.diagnostics.globals": ["RL"]
          }
        }
      }
    }

Common warnings and what they mean:

- `lowercase-global` - Using global variables with lowercase names (RL is intentional)
- `unused-local` - Local variables that aren't used
- `duplicate-set-field` - Redefining functions (callback functions are expected to be redefined)
- `missing-fields` - Table fields that might not exist
- `undefined-field` - Accessing fields that aren't documented

> Note: The `tools/ReiLua_API.lua` file now uses type annotations instead of function definitions for callbacks to prevent duplicate warnings.

---

## Troubleshooting

### "duplicate-set-field" Error

Problem: Getting warnings like `Duplicate field 'init'. (Lua Diagnostics. duplicate-set-field)` Why: The `tools/ReiLua_API.lua` file previously defined callback functions as empty function definitions. When you define them in your `main.lua`, LSP sees it as redefining the same field. Solution: The latest `tools/ReiLua_API.lua` now uses type annotations instead:

    -- Old way (caused warnings)
    function RL.init() end

    -- New way (no warnings)
    ---@type fun()
    RL.init = nil

Fix Steps: 1. Update `tools/ReiLua_API.lua` - Copy the latest version from the repository 2. Or add to diagnostics.disable in your configuration:

       {
         "diagnostics.disable": ["duplicate-set-field"]
       }

3. Restart Zed to reload the configuration

Benefits of the new approach:

- No duplicate warnings
- Still get autocomplete
- Still get documentation on hover
- Still get type checking

---

### Autocomplete Not Working

1. Restart Zed after configuration changes 2. Check LSP Status: Look for Lua Language Server in bottom-right status bar 3. Verify File Location: Ensure `tools/ReiLua_API.lua` is in the workspace 4. Check Console: Open Zed's log to see LSP errors

### Performance Issues

If the language server is slow:

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.workspace.maxPreload": 2000,
            "Lua.workspace.preloadFileSize": 1000
          }
        }
      }
    }

### Missing Documentation

Ensure hover is enabled:

    {
      "hover_popover_enabled": true
    }

---

## Advanced: Custom Annotations

You can extend `tools/ReiLua_API.lua` with your own game types:

    ---@class Player
    ---@field x number
    ---@field y number
    ---@field health number

    ---@class Enemy
    ---@field x number
    ---@field y number
    ---@field damage number

    -- Your game globals
    ---@type Player
    player = {}

    ---@type Enemy[]
    enemies = {}

---

## Keyboard Shortcuts in Zed

- Trigger Autocomplete: `Ctrl+Space` (Windows/Linux) or `Cmd+Space` (macOS)
- Show Documentation: Hover or `Ctrl+K Ctrl+I`
- Go to Definition: `F12` or `Cmd+Click`
- Find References: `Shift+F12`
- Rename Symbol: `F2`

---

## Additional Resources

- Lua Language Server GitHub
- LuaLS Annotations Guide
- Zed Documentation

---

## Example Project Structure

    my-reilua-game/
    ├── .luarc.json              # LuaLS configuration
    ├── .zed/
    │   └── settings.json        # Zed-specific settings
    ├── tools/ReiLua_API.lua           # API definitions (copy from ReiLua)
    ├── main.lua                 # Your game entry point
    ├── player.lua
    ├── enemy.lua
    └── assets/
        ├── sprites/
        └── sounds/

---

## Quick Start Template

Save this as `.luarc.json` in your project:

    {
      "runtime.version": "Lua 5.4",
      "completion.enable": true,
      "completion.callSnippet": "Replace",
      "diagnostics.globals": ["RL"],
      "diagnostics.disable": [
        "lowercase-global",
        "duplicate-set-field",
        "missing-fields"
      ],
      "workspace.checkThirdParty": false,
      "workspace.library": ["."],
      "hint.enable": true
    }

Save this as `.zed/settings.json`:

    {
      "lsp": {
        "lua-language-server": {
          "settings": {
            "Lua.hint.enable": true,
            "Lua.hint.paramName": "All",
            "Lua.hint.setType": true,
            "Lua.diagnostics.disable": [
              "lowercase-global",
              "duplicate-set-field",
              "missing-fields"
            ]
          }
        }
      },
      "inlay_hints": {
        "enabled": true
      }
    }

Then copy `tools/ReiLua_API.lua` to your project root, and you're ready to go!

---

Happy Coding!