Add game folder workflow, custom executable names, cross-platform tasks, and logging controls
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,6 @@
|
|||||||
.vscode
|
.vscode
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
# Projects - ignore all folders inside projects/ except the projects folder itself
|
||||||
|
projects/*/
|
||||||
|
!projects/README.md
|
||||||
@@ -3,7 +3,20 @@ include( CMakeDependentOption )
|
|||||||
include( EnumOption )
|
include( EnumOption )
|
||||||
|
|
||||||
cmake_minimum_required( VERSION 3.9 )
|
cmake_minimum_required( VERSION 3.9 )
|
||||||
project( ReiLua )
|
|
||||||
|
# Try to read custom project name from project.info
|
||||||
|
set( PROJECT_NAME_VAR "ReiLua" )
|
||||||
|
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/project.info" )
|
||||||
|
file( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/project.info" PROJECT_INFO_LINES )
|
||||||
|
foreach( LINE ${PROJECT_INFO_LINES} )
|
||||||
|
if( LINE MATCHES "^EXECUTABLE_NAME=(.+)$" )
|
||||||
|
set( PROJECT_NAME_VAR "${CMAKE_MATCH_1}" )
|
||||||
|
message( STATUS "Using custom executable name: ${PROJECT_NAME_VAR}" )
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project( ${PROJECT_NAME_VAR} )
|
||||||
|
|
||||||
# Find Python interpreter (python3 or python)
|
# Find Python interpreter (python3 or python)
|
||||||
find_package(Python3 COMPONENTS Interpreter)
|
find_package(Python3 COMPONENTS Interpreter)
|
||||||
@@ -36,6 +49,12 @@ if( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
|
|||||||
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
|
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Set compiler flags for Release builds
|
||||||
|
if( CMAKE_BUILD_TYPE STREQUAL "Release" )
|
||||||
|
add_definitions( -DNDEBUG )
|
||||||
|
message( STATUS "Release build - logging disabled by default" )
|
||||||
|
endif()
|
||||||
|
|
||||||
file( GLOB SOURCES src/*.c )
|
file( GLOB SOURCES src/*.c )
|
||||||
|
|
||||||
# Always embed logo files for splash screens
|
# Always embed logo files for splash screens
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern State* state;
|
extern State* state;
|
||||||
|
|
||||||
bool stateInit( int argn, const char** argc, const char* basePath );
|
bool stateInit( int argn, const char** argc, const char* basePath, bool enable_logging );
|
||||||
void stateContextInit();
|
void stateContextInit();
|
||||||
void stateInitInterpret( int argn, const char** argc );
|
void stateInitInterpret( int argn, const char** argc );
|
||||||
void stateFree();
|
void stateFree();
|
||||||
|
|||||||
BIN
projects/.DS_Store
vendored
BIN
projects/.DS_Store
vendored
Binary file not shown.
@@ -1,4 +1,24 @@
|
|||||||
# All projects go in this folder
|
# Projects
|
||||||
# Projects created by create_project.sh
|
|
||||||
|
|
||||||
Each project is a complete ReiLua-Enhanced setup ready to build.
|
This folder contains your game projects created with `scripts/create_project.sh`.
|
||||||
|
|
||||||
|
Each project is self-contained with:
|
||||||
|
- **game/** - Your game code and assets
|
||||||
|
- **build/** - Compiled executable
|
||||||
|
- **scripts/** - Build and run scripts
|
||||||
|
- All necessary ReiLua source files
|
||||||
|
|
||||||
|
## Create a New Project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /path/to/ReiLua-Enhanced
|
||||||
|
./scripts/create_project.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The script will guide you through setting up:
|
||||||
|
- Project name
|
||||||
|
- Executable name
|
||||||
|
- Author information
|
||||||
|
- Version and metadata
|
||||||
|
|
||||||
|
Your projects are automatically gitignored in the main repository.
|
||||||
|
|||||||
BIN
scripts/.DS_Store
vendored
BIN
scripts/.DS_Store
vendored
Binary file not shown.
@@ -72,8 +72,38 @@ cd build || exit 1
|
|||||||
echo "Cleaning old embedded files..."
|
echo "Cleaning old embedded files..."
|
||||||
rm -f embedded_main.h embedded_assets.h
|
rm -f embedded_main.h embedded_assets.h
|
||||||
|
|
||||||
# Check for Lua files
|
# Auto-copy from game folder if it exists
|
||||||
echo ""
|
echo ""
|
||||||
|
if [ -d "../game" ]; then
|
||||||
|
echo "Found game/ folder - auto-copying contents to build..."
|
||||||
|
|
||||||
|
# Copy all Lua files from game folder EXCEPT ReiLua_API.lua
|
||||||
|
if ls ../game/*.lua 1> /dev/null 2>&1; then
|
||||||
|
for lua_file in ../game/*.lua; do
|
||||||
|
filename=$(basename "$lua_file")
|
||||||
|
if [ "$filename" != "ReiLua_API.lua" ]; then
|
||||||
|
cp "$lua_file" .
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
LUA_COUNT=$(ls *.lua 2>/dev/null | wc -l)
|
||||||
|
echo " ✓ Copied $LUA_COUNT Lua file(s)"
|
||||||
|
else
|
||||||
|
echo " ⚠ No Lua files found in game/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy assets folder if it exists
|
||||||
|
if [ -d "../game/assets" ]; then
|
||||||
|
rm -rf assets
|
||||||
|
cp -r ../game/assets .
|
||||||
|
ASSET_COUNT=$(find assets -type f 2>/dev/null | wc -l)
|
||||||
|
echo " ✓ Copied assets/ ($ASSET_COUNT files)"
|
||||||
|
else
|
||||||
|
echo " ℹ No assets folder in game/"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for Lua files
|
||||||
echo "Checking for Lua files..."
|
echo "Checking for Lua files..."
|
||||||
LUA_FILES=$(ls *.lua 2>/dev/null | wc -l)
|
LUA_FILES=$(ls *.lua 2>/dev/null | wc -l)
|
||||||
|
|
||||||
@@ -81,9 +111,15 @@ if [ "$LUA_FILES" -eq 0 ]; then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "WARNING: No Lua files found in build directory!"
|
echo "WARNING: No Lua files found in build directory!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please copy your Lua files:"
|
if [ -d "../game" ]; then
|
||||||
echo " cd build"
|
echo "No Lua files found in game/ folder either."
|
||||||
echo " cp ../your_game/*.lua ."
|
echo "Add your main.lua to game/ folder and try again."
|
||||||
|
else
|
||||||
|
echo "Tip: Create a game/ folder in project root and add main.lua there."
|
||||||
|
echo "Or manually copy files:"
|
||||||
|
echo " cd build"
|
||||||
|
echo " cp ../your_game/*.lua ."
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Do you want to continue anyway? (y/N): " -n 1 -r
|
read -p "Do you want to continue anyway? (y/N): " -n 1 -r
|
||||||
echo ""
|
echo ""
|
||||||
@@ -102,10 +138,16 @@ if [ ! -d "assets" ]; then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "WARNING: No assets folder found!"
|
echo "WARNING: No assets folder found!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "To embed assets, create the folder and copy files:"
|
if [ -d "../game" ]; then
|
||||||
echo " cd build"
|
echo "No assets found in game/assets/ folder."
|
||||||
echo " mkdir assets"
|
echo "Add assets to game/assets/ if you need them embedded."
|
||||||
echo " cp ../your_game/assets/* assets/"
|
else
|
||||||
|
echo "Tip: Create game/assets/ in project root for auto-copy."
|
||||||
|
echo "Or manually:"
|
||||||
|
echo " cd build"
|
||||||
|
echo " mkdir assets"
|
||||||
|
echo " cp ../your_game/assets/* assets/"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Do you want to continue without assets? (y/N): " -n 1 -r
|
read -p "Do you want to continue without assets? (y/N): " -n 1 -r
|
||||||
echo ""
|
echo ""
|
||||||
@@ -200,26 +242,41 @@ echo "================================"
|
|||||||
echo "Build Complete!"
|
echo "Build Complete!"
|
||||||
echo "================================"
|
echo "================================"
|
||||||
|
|
||||||
# Detect executable name based on platform
|
# Read executable name from project.info
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
EXE_NAME="ReiLua"
|
||||||
EXE_NAME="ReiLua"
|
if [ -f "../project.info" ]; then
|
||||||
else
|
EXE_NAME=$(grep "^EXECUTABLE_NAME=" ../project.info | cut -d'=' -f2)
|
||||||
EXE_NAME="ReiLua.exe"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EXESIZE=$(du -h "$EXE_NAME" | cut -f1)
|
# Detect executable extension based on platform
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
EXE_FILE="$EXE_NAME"
|
||||||
|
else
|
||||||
|
EXE_FILE="${EXE_NAME}.exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$EXE_FILE" ]; then
|
||||||
|
echo "Warning: Expected executable not found: $EXE_FILE"
|
||||||
|
echo "Falling back to ReiLua..."
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
EXE_FILE="ReiLua"
|
||||||
|
else
|
||||||
|
EXE_FILE="ReiLua.exe"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
EXESIZE=$(du -h "$EXE_FILE" | cut -f1)
|
||||||
echo ""
|
echo ""
|
||||||
echo "Executable: $EXE_NAME ($EXESIZE)"
|
echo "Executable: $EXE_FILE ($EXESIZE)"
|
||||||
echo "Location: $(pwd)/$EXE_NAME"
|
echo "Location: $(pwd)/$EXE_FILE"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Your game is ready for distribution!"
|
echo "Your game is ready for distribution!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "To test the release build:"
|
echo "To test the release build:"
|
||||||
echo " ./$EXE_NAME --log (with console)"
|
echo " ./$EXE_FILE --log (with console)"
|
||||||
echo " ./$EXE_NAME (production mode)"
|
echo " ./$EXE_FILE (production mode)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "To distribute:"
|
echo "To distribute:"
|
||||||
echo " - Copy $EXE_NAME to your distribution folder"
|
echo " - Copy $EXE_FILE to your distribution folder"
|
||||||
echo " - Rename it to your game name (optional)"
|
|
||||||
echo " - That's it! Single file distribution!"
|
echo " - That's it! Single file distribution!"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ mkdir -p "$PROJECT_DIR"
|
|||||||
echo "Copying ReiLua-Enhanced files..."
|
echo "Copying ReiLua-Enhanced files..."
|
||||||
|
|
||||||
# Create directory structure first
|
# Create directory structure first
|
||||||
mkdir -p "$PROJECT_DIR"/{src,include,lib,scripts/macos,fonts,logo,cmake}
|
mkdir -p "$PROJECT_DIR"/{src,include,lib,scripts/macos,fonts,logo,cmake,game}
|
||||||
|
|
||||||
# Copy files using find to preserve structure, excluding unnecessary files
|
# Copy files using find to preserve structure, excluding unnecessary files
|
||||||
(cd "$SCRIPT_DIR/.." && \
|
(cd "$SCRIPT_DIR/.." && \
|
||||||
@@ -140,7 +140,7 @@ mkdir -p "$PROJECT_DIR"/{src,include,lib,scripts/macos,fonts,logo,cmake}
|
|||||||
! -name '*.md' \
|
! -name '*.md' \
|
||||||
! -name 'changelog' \
|
! -name 'changelog' \
|
||||||
! -name 'devnotes' \
|
! -name 'devnotes' \
|
||||||
! -name '*.png' \
|
! -name 'logo.png' \
|
||||||
! -name 'LICENSE' \
|
! -name 'LICENSE' \
|
||||||
! -name 'zed.sample.settings.json' \
|
! -name 'zed.sample.settings.json' \
|
||||||
! -name 'create_project.sh' \
|
! -name 'create_project.sh' \
|
||||||
@@ -361,21 +361,24 @@ EOFBUNDLE
|
|||||||
|
|
||||||
# Replace placeholders in create_app_bundle.sh
|
# Replace placeholders in create_app_bundle.sh
|
||||||
if [ -f "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" ]; then
|
if [ -f "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" ]; then
|
||||||
# Cross-platform sed: detect OS and use appropriate syntax
|
# Use direct sed replacement for macOS (creates backup with different approach)
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# macOS requires empty string after -i
|
# macOS sed
|
||||||
SED_INPLACE="sed -i ''"
|
sed -i '' "s/__PROJECT_NAME__/$PROJECT_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i '' "s/__EXECUTABLE_NAME__/$EXECUTABLE_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i '' "s/__BUNDLE_ID__/$BUNDLE_ID/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i '' "s/__VERSION__/$VERSION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i '' "s/__AUTHOR_NAME__/$AUTHOR_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i '' "s/__DESCRIPTION__/$DESCRIPTION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
else
|
else
|
||||||
# Linux/Windows Git Bash
|
# Linux/Windows Git Bash
|
||||||
SED_INPLACE="sed -i"
|
sed -i "s/__PROJECT_NAME__/$PROJECT_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i "s/__EXECUTABLE_NAME__/$EXECUTABLE_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i "s/__BUNDLE_ID__/$BUNDLE_ID/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i "s/__VERSION__/$VERSION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i "s/__AUTHOR_NAME__/$AUTHOR_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
|
sed -i "s/__DESCRIPTION__/$DESCRIPTION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$SED_INPLACE "s/__PROJECT_NAME__/$PROJECT_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
|
||||||
$SED_INPLACE "s/__EXECUTABLE_NAME__/$EXECUTABLE_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
|
||||||
$SED_INPLACE "s/__BUNDLE_ID__/$BUNDLE_ID/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
|
||||||
$SED_INPLACE "s/__VERSION__/$VERSION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
|
||||||
$SED_INPLACE "s/__AUTHOR_NAME__/$AUTHOR_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
|
||||||
$SED_INPLACE "s/__DESCRIPTION__/$DESCRIPTION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
|
||||||
chmod +x "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
chmod +x "$PROJECT_DIR/scripts/macos/create_app_bundle.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -406,62 +409,91 @@ $DESCRIPTION
|
|||||||
- **Created:** $(date +%Y-%m-%d)
|
- **Created:** $(date +%Y-%m-%d)
|
||||||
- **Built with:** ReiLua-Enhanced
|
- **Built with:** ReiLua-Enhanced
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
### Development Build
|
|
||||||
\`\`\`bash
|
|
||||||
./scripts/build_dev.sh
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
### Release Build
|
|
||||||
\`\`\`bash
|
|
||||||
# Copy your Lua files and assets
|
|
||||||
mkdir -p build
|
|
||||||
cp *.lua build/
|
|
||||||
cp -r assets build/
|
|
||||||
|
|
||||||
# Build
|
|
||||||
./scripts/build_release.sh
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
### macOS App Bundle
|
|
||||||
\`\`\`bash
|
|
||||||
./scripts/macos/create_app_bundle.sh
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
\`\`\`
|
\`\`\`
|
||||||
$PROJECT_NAME/
|
$PROJECT_NAME/
|
||||||
├── main.lua # Your game entry point
|
├── game/ # Your game files (edit here!)
|
||||||
├── assets/ # Game assets (images, sounds, etc.)
|
│ ├── main.lua # Game entry point
|
||||||
├── build/ # Build output directory
|
│ └── assets/ # Game assets
|
||||||
|
├── build/ # Build output (auto-generated)
|
||||||
├── scripts/ # Build scripts
|
├── scripts/ # Build scripts
|
||||||
│ ├── build_dev.sh
|
|
||||||
│ ├── build_release.sh
|
|
||||||
│ └── macos/
|
|
||||||
│ ├── build_static_libs.sh
|
|
||||||
│ └── create_app_bundle.sh
|
|
||||||
├── src/ # ReiLua C source
|
├── src/ # ReiLua C source
|
||||||
├── include/ # Headers
|
├── include/ # Headers
|
||||||
└── lib/ # Static libraries
|
└── lib/ # Static libraries
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
|
**Important:** All your game development happens in the \`game/\` folder!
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
### 1. Edit Your Game
|
||||||
|
|
||||||
|
All your game files go in the \`game/\` folder:
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
game/
|
||||||
|
├── main.lua # Your game code
|
||||||
|
├── player.lua # Game modules
|
||||||
|
├── enemy.lua
|
||||||
|
└── assets/
|
||||||
|
├── sprites/
|
||||||
|
│ ├── player.png
|
||||||
|
│ └── enemy.png
|
||||||
|
└── sounds/
|
||||||
|
└── music.wav
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### 2. Build for Development
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
./scripts/build_dev.sh
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### 3. Run Your Game
|
||||||
|
|
||||||
|
From project root, ReiLua will automatically load from \`game/\` folder:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
./build/ReiLua --no-logo --log
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
The engine checks paths in this order:
|
||||||
|
1. \`game/main.lua\` (if game folder exists)
|
||||||
|
2. \`main.lua\` (current directory)
|
||||||
|
3. Embedded files (release builds)
|
||||||
|
|
||||||
|
### 4. Release Build
|
||||||
|
|
||||||
|
Release build automatically copies from \`game/\` folder:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
./scripts/build_release.sh
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
This will:
|
||||||
|
- Copy all \`.lua\` files from \`game/\` to \`build/\`
|
||||||
|
- Copy \`game/assets/\` to \`build/assets/\`
|
||||||
|
- Embed everything into the executable
|
||||||
|
|
||||||
## Game Development
|
## Game Development
|
||||||
|
|
||||||
Edit \`main.lua\` and add your game code:
|
Edit \`game/main.lua\`:
|
||||||
|
|
||||||
\`\`\`lua
|
\`\`\`lua
|
||||||
function init()
|
function RL.init()
|
||||||
-- Initialize your game
|
-- Load your assets
|
||||||
|
player = RL.LoadTexture("assets/sprites/player.png")
|
||||||
end
|
end
|
||||||
|
|
||||||
function update(dt)
|
function RL.update(delta)
|
||||||
-- Update game logic
|
-- Update game logic
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw()
|
function RL.draw()
|
||||||
-- Draw your game
|
-- Draw your game
|
||||||
|
RL.ClearBackground(RL.RAYWHITE)
|
||||||
|
RL.DrawTexture(player, 100, 100, RL.WHITE)
|
||||||
end
|
end
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
@@ -490,6 +522,24 @@ hdiutil create -volname '$PROJECT_NAME' \\
|
|||||||
# The executable is: build/ReiLua (rename to ${EXECUTABLE_NAME})
|
# The executable is: build/ReiLua (rename to ${EXECUTABLE_NAME})
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
|
## Why the game/ Folder?
|
||||||
|
|
||||||
|
The \`game/\` folder keeps your work organized and safe:
|
||||||
|
|
||||||
|
- **Separation:** Your game files stay separate from build artifacts
|
||||||
|
- **Safety:** Rebuilding won't delete your game files
|
||||||
|
- **Clarity:** Anyone can see where the game code lives
|
||||||
|
- **Automation:** Release builds auto-copy from game/ folder
|
||||||
|
|
||||||
|
## Editor Setup
|
||||||
|
|
||||||
|
This project includes configurations for:
|
||||||
|
- **Lua Language Server** (\`.luarc.json\`) - Autocomplete and type checking
|
||||||
|
- **Zed Editor** (\`.zed/settings.json\`) - LSP configuration
|
||||||
|
- **Zed Tasks** (\`.zed/tasks.json\`) - Build and run commands
|
||||||
|
|
||||||
|
Open the project in Zed and use \`Cmd+Shift+P\` → "Run Task" to build and run.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Add your license information here.
|
Add your license information here.
|
||||||
@@ -500,40 +550,41 @@ Built with [ReiLua-Enhanced](https://github.com/nullstare/ReiLua)
|
|||||||
EOFREADME
|
EOFREADME
|
||||||
|
|
||||||
# Create example main.lua
|
# Create example main.lua
|
||||||
cat > "$PROJECT_DIR/main.lua" << EOFLUA
|
cat > "$PROJECT_DIR/game/main.lua" << EOFLUA
|
||||||
-- $PROJECT_NAME
|
-- $PROJECT_NAME
|
||||||
-- $DESCRIPTION
|
-- $DESCRIPTION
|
||||||
-- Author: $AUTHOR_NAME
|
-- Author: $AUTHOR_NAME
|
||||||
|
|
||||||
function init()
|
function RL.init()
|
||||||
|
RL.SetWindowTitle( "$PROJECT_NAME" )
|
||||||
|
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||||
|
|
||||||
print("$PROJECT_NAME initialized!")
|
print("$PROJECT_NAME initialized!")
|
||||||
print("Version: $VERSION")
|
print("Version: $VERSION")
|
||||||
print("Author: $AUTHOR_NAME")
|
print("Author: $AUTHOR_NAME")
|
||||||
|
|
||||||
-- Initialize your game here
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function update(dt)
|
function RL.update( delta )
|
||||||
-- Update game logic here
|
-- Game logic goes here
|
||||||
-- dt = delta time in seconds
|
-- delta is time since last frame in seconds
|
||||||
end
|
|
||||||
|
|
||||||
function draw()
|
if RL.IsKeyPressed( RL.KEY_ESCAPE ) then
|
||||||
-- Draw your game here
|
RL.CloseWindow()
|
||||||
RL.clearBackground(RL.RAYWHITE)
|
|
||||||
|
|
||||||
RL.drawText("$PROJECT_NAME", 10, 10, 40, RL.BLACK)
|
|
||||||
RL.drawText("Press ESC to exit", 10, 60, 20, RL.DARKGRAY)
|
|
||||||
|
|
||||||
if RL.isKeyPressed(RL.KEY_ESCAPE) then
|
|
||||||
RL.closeWindow()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function RL.draw()
|
||||||
|
RL.ClearBackground( RL.RAYWHITE )
|
||||||
|
|
||||||
|
RL.DrawText( "$PROJECT_NAME", { 10, 10 }, 40, RL.BLACK )
|
||||||
|
RL.DrawText( "Press ESC to exit", { 10, 60 }, 20, RL.DARKGRAY )
|
||||||
|
end
|
||||||
EOFLUA
|
EOFLUA
|
||||||
|
|
||||||
# Create assets directory
|
# Create assets directory in game folder
|
||||||
mkdir -p "$PROJECT_DIR/assets"
|
mkdir -p "$PROJECT_DIR/game/assets"
|
||||||
cat > "$PROJECT_DIR/assets/.gitkeep" << EOFKEEP
|
cat > "$PROJECT_DIR/game/assets/.gitkeep" << EOFKEEP
|
||||||
|
# Game assets folder
|
||||||
# Place your game assets here:
|
# Place your game assets here:
|
||||||
# - Images (.png, .jpg)
|
# - Images (.png, .jpg)
|
||||||
# - Sounds (.wav, .ogg, .mp3)
|
# - Sounds (.wav, .ogg, .mp3)
|
||||||
@@ -541,6 +592,157 @@ cat > "$PROJECT_DIR/assets/.gitkeep" << EOFKEEP
|
|||||||
# - Other resources
|
# - Other resources
|
||||||
EOFKEEP
|
EOFKEEP
|
||||||
|
|
||||||
|
# Copy ReiLua API definitions for LSP to game folder
|
||||||
|
echo "Setting up game folder for development..."
|
||||||
|
if [ -f "$SCRIPT_DIR/../tools/ReiLua_API.lua" ]; then
|
||||||
|
cp "$SCRIPT_DIR/../tools/ReiLua_API.lua" "$PROJECT_DIR/game/"
|
||||||
|
echo " ✓ game/ReiLua_API.lua"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create .luarc.json for Lua Language Server in game folder
|
||||||
|
cat > "$PROJECT_DIR/game/.luarc.json" << EOFLUARC
|
||||||
|
{
|
||||||
|
"runtime.version": "Lua 5.4",
|
||||||
|
"completion.enable": true,
|
||||||
|
"completion.callSnippet": "Replace",
|
||||||
|
"completion.displayContext": 3,
|
||||||
|
"diagnostics.globals": ["RL"],
|
||||||
|
"diagnostics.disable": [
|
||||||
|
"lowercase-global",
|
||||||
|
"unused-local",
|
||||||
|
"duplicate-set-field",
|
||||||
|
"missing-fields",
|
||||||
|
"undefined-field"
|
||||||
|
],
|
||||||
|
"workspace.checkThirdParty": false,
|
||||||
|
"workspace.library": ["ReiLua_API.lua"],
|
||||||
|
"hint.enable": true,
|
||||||
|
"hint.paramName": "All",
|
||||||
|
"hint.setType": true,
|
||||||
|
"hint.paramType": true
|
||||||
|
}
|
||||||
|
EOFLUARC
|
||||||
|
|
||||||
|
echo " ✓ game/.luarc.json"
|
||||||
|
|
||||||
|
# Create Zed editor configuration in project root
|
||||||
|
echo "Setting up Zed editor configuration..."
|
||||||
|
mkdir -p "$PROJECT_DIR/.zed"
|
||||||
|
mkdir -p "$PROJECT_DIR/scripts/run"
|
||||||
|
|
||||||
|
# Create run scripts for tasks (cross-platform)
|
||||||
|
cat > "$PROJECT_DIR/scripts/run/run_dev.sh" << 'EOFRUNDEV'
|
||||||
|
#!/bin/bash
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
||||||
|
EXE=$(grep EXECUTABLE_NAME= project.info | cut -d= -f2)
|
||||||
|
./build/${EXE}.exe --no-logo --log
|
||||||
|
else
|
||||||
|
EXE=$(grep EXECUTABLE_NAME= project.info | cut -d= -f2)
|
||||||
|
./build/$EXE --no-logo --log
|
||||||
|
fi
|
||||||
|
EOFRUNDEV
|
||||||
|
chmod +x "$PROJECT_DIR/scripts/run/run_dev.sh"
|
||||||
|
|
||||||
|
cat > "$PROJECT_DIR/scripts/run/run_no_splash.sh" << 'EOFRUNNOSPLASH'
|
||||||
|
#!/bin/bash
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
||||||
|
EXE=$(grep EXECUTABLE_NAME= project.info | cut -d= -f2)
|
||||||
|
./build/${EXE}.exe --no-logo
|
||||||
|
else
|
||||||
|
EXE=$(grep EXECUTABLE_NAME= project.info | cut -d= -f2)
|
||||||
|
./build/$EXE --no-logo
|
||||||
|
fi
|
||||||
|
EOFRUNNOSPLASH
|
||||||
|
chmod +x "$PROJECT_DIR/scripts/run/run_no_splash.sh"
|
||||||
|
|
||||||
|
cat > "$PROJECT_DIR/scripts/run/run_release.sh" << 'EOFRUNRELEASE'
|
||||||
|
#!/bin/bash
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
||||||
|
EXE=$(grep EXECUTABLE_NAME= project.info | cut -d= -f2)
|
||||||
|
./build/${EXE}.exe
|
||||||
|
else
|
||||||
|
EXE=$(grep EXECUTABLE_NAME= project.info | cut -d= -f2)
|
||||||
|
./build/$EXE
|
||||||
|
fi
|
||||||
|
EOFRUNRELEASE
|
||||||
|
chmod +x "$PROJECT_DIR/scripts/run/run_release.sh"
|
||||||
|
|
||||||
|
cat > "$PROJECT_DIR/.zed/settings.json" << EOFZED
|
||||||
|
{
|
||||||
|
"inlay_hints": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"lsp": {
|
||||||
|
"lua-language-server": {
|
||||||
|
"settings": {
|
||||||
|
"Lua.runtime.version": "Lua 5.4",
|
||||||
|
"Lua.workspace.library": [
|
||||||
|
"game/ReiLua_API.lua"
|
||||||
|
],
|
||||||
|
"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,
|
||||||
|
"Lua.hint.paramType": true,
|
||||||
|
"Lua.diagnostics.disable": [
|
||||||
|
"lowercase-global",
|
||||||
|
"unused-local",
|
||||||
|
"duplicate-set-field",
|
||||||
|
"missing-fields",
|
||||||
|
"undefined-field"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOFZED
|
||||||
|
|
||||||
|
cat > "$PROJECT_DIR/.zed/tasks.json" << EOFTASKS
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"label": "Run Game (Dev)",
|
||||||
|
"command": "./scripts/run/run_dev.sh",
|
||||||
|
"args": [],
|
||||||
|
"use_new_terminal": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Game (No Splash)",
|
||||||
|
"command": "./scripts/run/run_no_splash.sh",
|
||||||
|
"args": [],
|
||||||
|
"use_new_terminal": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Game (Release)",
|
||||||
|
"command": "./scripts/run/run_release.sh",
|
||||||
|
"args": [],
|
||||||
|
"use_new_terminal": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Build Dev",
|
||||||
|
"command": "./scripts/build_dev.sh",
|
||||||
|
"args": [],
|
||||||
|
"use_new_terminal": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Build Release",
|
||||||
|
"command": "./scripts/build_release.sh",
|
||||||
|
"args": [],
|
||||||
|
"use_new_terminal": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
EOFTASKS
|
||||||
|
|
||||||
|
echo " ✓ .zed/settings.json"
|
||||||
|
echo " ✓ .zed/tasks.json"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "╔════════════════════════════════════════════════════════════════════╗"
|
echo "╔════════════════════════════════════════════════════════════════════╗"
|
||||||
echo "║ ║"
|
echo "║ ║"
|
||||||
@@ -556,18 +758,22 @@ echo " Author: $AUTHOR_NAME"
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Next Steps:"
|
echo "Next Steps:"
|
||||||
echo " 1. cd projects/$PROJECT_NAME"
|
echo " 1. cd projects/$PROJECT_NAME"
|
||||||
echo " 2. Edit main.lua (your game code)"
|
echo " 2. Edit game/main.lua (your game code)"
|
||||||
echo " 3. Add assets to assets/ folder"
|
echo " 3. Add assets to game/assets/ folder"
|
||||||
echo " 4. Build: ./scripts/build_dev.sh"
|
echo " 4. Build: ./scripts/build_dev.sh"
|
||||||
echo " 5. Run: ./build/ReiLua"
|
echo " 5. Run: ./build/ReiLua"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Files Created:"
|
echo "Files Created:"
|
||||||
echo " ✓ main.lua - Game entry point"
|
echo " ✓ game/main.lua - Game entry point"
|
||||||
|
echo " ✓ game/assets/ - Asset directory"
|
||||||
|
echo " ✓ game/ReiLua_API.lua - API definitions for LSP"
|
||||||
|
echo " ✓ game/.luarc.json - Lua Language Server config"
|
||||||
|
echo " ✓ .zed/settings.json - Zed editor config"
|
||||||
|
echo " ✓ .zed/tasks.json - Build and run tasks"
|
||||||
echo " ✓ project.info - Project metadata"
|
echo " ✓ project.info - Project metadata"
|
||||||
echo " ✓ README.md - Project documentation"
|
echo " ✓ README.md - Project documentation"
|
||||||
echo " ✓ resources.rc - Windows metadata (embedded in .exe)"
|
echo " ✓ resources.rc - Windows metadata (embedded in .exe)"
|
||||||
echo " ✓ scripts/macos/create_app_bundle.sh - macOS bundle with metadata"
|
echo " ✓ scripts/macos/create_app_bundle.sh - macOS bundle with metadata"
|
||||||
echo " ✓ assets/ - Asset directory"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Build Scripts Updated:"
|
echo "Build Scripts Updated:"
|
||||||
echo " ✓ Lua path: ../lua (sibling directory)"
|
echo " ✓ Lua path: ../lua (sibling directory)"
|
||||||
|
|||||||
42
src/main.c
42
src/main.c
@@ -33,12 +33,14 @@ int main( int argn, const char** argc ) {
|
|||||||
bool interpret_mode = false;
|
bool interpret_mode = false;
|
||||||
bool show_console = false;
|
bool show_console = false;
|
||||||
bool skip_splash = false;
|
bool skip_splash = false;
|
||||||
|
bool enable_logging = false;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Check for --log and --no-logo arguments */
|
/* Check for --log and --no-logo arguments */
|
||||||
for ( int i = 1; i < argn; i++ ) {
|
for ( int i = 1; i < argn; i++ ) {
|
||||||
if ( strcmp( argc[i], "--log" ) == 0 ) {
|
if ( strcmp( argc[i], "--log" ) == 0 ) {
|
||||||
show_console = true;
|
show_console = true;
|
||||||
|
enable_logging = true;
|
||||||
}
|
}
|
||||||
if ( strcmp( argc[i], "--no-logo" ) == 0 ) {
|
if ( strcmp( argc[i], "--no-logo" ) == 0 ) {
|
||||||
skip_splash = true;
|
skip_splash = true;
|
||||||
@@ -59,11 +61,13 @@ int main( int argn, const char** argc ) {
|
|||||||
FreeConsole();
|
FreeConsole();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Check for --no-logo on non-Windows platforms */
|
/* Check for --no-logo and --log on non-Windows platforms */
|
||||||
for ( int i = 1; i < argn; i++ ) {
|
for ( int i = 1; i < argn; i++ ) {
|
||||||
if ( strcmp( argc[i], "--no-logo" ) == 0 ) {
|
if ( strcmp( argc[i], "--no-logo" ) == 0 ) {
|
||||||
skip_splash = true;
|
skip_splash = true;
|
||||||
break;
|
}
|
||||||
|
if ( strcmp( argc[i], "--log" ) == 0 ) {
|
||||||
|
enable_logging = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -96,26 +100,44 @@ int main( int argn, const char** argc ) {
|
|||||||
else {
|
else {
|
||||||
/* Only flags were provided, use default path search */
|
/* Only flags were provided, use default path search */
|
||||||
char testPath[ STRING_LEN ] = { '\0' };
|
char testPath[ STRING_LEN ] = { '\0' };
|
||||||
sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
|
|
||||||
|
|
||||||
|
/* Check for game/main.lua in working directory */
|
||||||
|
sprintf( testPath, "%s/game/main.lua", GetWorkingDirectory() );
|
||||||
if ( FileExists( testPath ) ) {
|
if ( FileExists( testPath ) ) {
|
||||||
sprintf( basePath, "%s", GetWorkingDirectory() );
|
sprintf( basePath, "%s/game/", GetWorkingDirectory() );
|
||||||
}
|
}
|
||||||
|
/* Check for main.lua in working directory */
|
||||||
else {
|
else {
|
||||||
sprintf( basePath, "%s", GetApplicationDirectory() );
|
sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
|
||||||
|
if ( FileExists( testPath ) ) {
|
||||||
|
sprintf( basePath, "%s", GetWorkingDirectory() );
|
||||||
|
}
|
||||||
|
/* Check exe directory */
|
||||||
|
else {
|
||||||
|
sprintf( basePath, "%s", GetApplicationDirectory() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If no argument given, check current directory first, then exe directory. */
|
/* If no argument given, check game folder first, then current directory, then exe directory. */
|
||||||
else {
|
else {
|
||||||
char testPath[ STRING_LEN ] = { '\0' };
|
char testPath[ STRING_LEN ] = { '\0' };
|
||||||
sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
|
|
||||||
|
|
||||||
|
/* Check for game/main.lua in working directory */
|
||||||
|
sprintf( testPath, "%s/game/main.lua", GetWorkingDirectory() );
|
||||||
if ( FileExists( testPath ) ) {
|
if ( FileExists( testPath ) ) {
|
||||||
sprintf( basePath, "%s", GetWorkingDirectory() );
|
sprintf( basePath, "%s/game/", GetWorkingDirectory() );
|
||||||
}
|
}
|
||||||
|
/* Check for main.lua in working directory */
|
||||||
else {
|
else {
|
||||||
sprintf( basePath, "%s", GetApplicationDirectory() );
|
sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
|
||||||
|
if ( FileExists( testPath ) ) {
|
||||||
|
sprintf( basePath, "%s", GetWorkingDirectory() );
|
||||||
|
}
|
||||||
|
/* Check exe directory */
|
||||||
|
else {
|
||||||
|
sprintf( basePath, "%s", GetApplicationDirectory() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +157,7 @@ int main( int argn, const char** argc ) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printVersion();
|
printVersion();
|
||||||
stateInit( argn, argc, basePath );
|
stateInit( argn, argc, basePath, enable_logging );
|
||||||
|
|
||||||
/* Show splash screens if not skipped */
|
/* Show splash screens if not skipped */
|
||||||
if ( !skip_splash ) {
|
if ( !skip_splash ) {
|
||||||
|
|||||||
16
src/state.c
16
src/state.c
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
State* state;
|
State* state;
|
||||||
|
|
||||||
bool stateInit( int argn, const char** argc, const char* basePath ) {
|
bool stateInit( int argn, const char** argc, const char* basePath, bool enable_logging ) {
|
||||||
state = malloc( sizeof( State ) );
|
state = malloc( sizeof( State ) );
|
||||||
|
|
||||||
state->basePath = malloc( STRING_LEN * sizeof( char ) );
|
state->basePath = malloc( STRING_LEN * sizeof( char ) );
|
||||||
@@ -36,6 +36,20 @@ bool stateInit( int argn, const char** argc, const char* basePath ) {
|
|||||||
state->mouseScale = (Vector2){ 1, 1 };
|
state->mouseScale = (Vector2){ 1, 1 };
|
||||||
state->customFontLoaded = false;
|
state->customFontLoaded = false;
|
||||||
|
|
||||||
|
/* Set log level based on build type and --log flag */
|
||||||
|
#ifdef NDEBUG
|
||||||
|
/* Release build - only show warnings/errors unless --log is specified */
|
||||||
|
if ( enable_logging ) {
|
||||||
|
SetTraceLogLevel( LOG_INFO );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetTraceLogLevel( LOG_WARNING );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* Debug/Dev build - always show all logs */
|
||||||
|
SetTraceLogLevel( LOG_INFO );
|
||||||
|
#endif
|
||||||
|
|
||||||
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
|
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
|
||||||
|
|
||||||
if ( !IsWindowReady() ) {
|
if ( !IsWindowReady() ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user