Skip to content

Latest commit

 

History

History
208 lines (166 loc) · 4.93 KB

File metadata and controls

208 lines (166 loc) · 4.93 KB

Lua Game Example - Complete Setup

This project demonstrates a complete Lua game development environment with TypeScript/JavaScript integration.

Project Status

All components successfully set up:

  • LOVE2D game (Space Shooter)
  • TypeScript integration examples
  • JavaScript integration examples
  • Cross-platform installation scripts
  • Cross-platform start scripts
  • Type declarations for untyped libraries
  • No linting errors
  • No border radius in graphics

Quick Start Guide

1. Installation

Run the installation script for your platform:

macOS/Linux:

./install.sh

Windows:

install.bat

This will:

  • Guide you through LOVE2D installation
  • Guide you through Node.js installation
  • Automatically install npm dependencies
  • Verify all installations

2. Running the Project

Use the start script for an interactive menu:

macOS/Linux:

./start.sh

Windows:

start.bat

Menu options:

  1. Run LOVE2D game only
  2. Run JavaScript backend only
  3. Run TypeScript backend only
  4. Run game + JavaScript backend
  5. Run game + TypeScript backend
  6. Run all services together

3. Manual Execution

Run the game:

love .

Run JavaScript examples:

cd integration
npm start
# or
node lua-runner.js

Run TypeScript examples:

cd integration
npm run start:ts
# or
npx ts-node lua-bridge.ts

Build TypeScript to Lua:

cd integration
npm run build:lua

Project Structure

lua-example/
├── install.sh              # Installation script (macOS/Linux)
├── install.bat             # Installation script (Windows)
├── start.sh                # Start script with menu (macOS/Linux)
├── start.bat               # Start script with menu (Windows)
├── main.lua                # Main game code
├── conf.lua                # LOVE2D configuration
├── README.md               # Main documentation
├── START_SCRIPTS.md        # Start script documentation
├── assets/                 # Game assets folder
├── logs/                   # Backend service logs
└── integration/            # TypeScript/JavaScript integration
    ├── lua-bridge.ts       # TypeScript-Lua bridge
    ├── lua-runner.js       # JavaScript examples
    ├── tstl-game.ts        # TypeScript to Lua example
    ├── package.json        # npm configuration
    ├── tsconfig.json       # TypeScript config
    ├── tsconfig.tstl.json  # TypeScriptToLua config
    └── types/              # Type declarations
        ├── fengari.d.ts
        ├── fengari-interop.d.ts
        └── README.md

Technologies Used

Frontend (Game)

  • LOVE2D 11.4: Lua game framework
  • Lua: Programming language
  • Procedural graphics (no sprites)
  • Particle systems
  • Game state management

Backend (Integration)

  • Node.js: JavaScript runtime
  • TypeScript: Type-safe JavaScript
  • Fengari: Lua VM in pure JavaScript
  • Wasmoon: Lua 5.4 via WebAssembly
  • TypeScriptToLua: Compile TypeScript to Lua

Features

Game Features

  • Space shooter gameplay
  • Procedural graphics with glow effects
  • Particle explosion effects
  • Parallax scrolling stars
  • Multiple enemy types
  • Score tracking
  • Lives system

Integration Features

  • Execute Lua code from JavaScript/TypeScript
  • Call Lua functions from JS/TS
  • Type-safe Lua bindings
  • Entity system examples
  • Game engine bridge patterns
  • Multiple Lua runtime options

Game Controls

Key Action
W / Up Arrow Move up
S / Down Arrow Move down
A / Left Arrow Move left
D / Right Arrow Move right
Space Shoot / Start game

Development Notes

  • No emojis in documentation
  • No border radius in graphics (sharp edges)
  • Cross-platform compatible
  • Type-safe TypeScript integration
  • Zero linting errors
  • Comprehensive error handling

Scripts Summary

Script Platform Purpose
install.sh macOS/Linux Interactive installation
install.bat Windows Interactive installation
start.sh macOS/Linux Launch services menu
start.bat Windows Launch services menu

npm Scripts

From the integration/ directory:

Command Description
npm start Run JavaScript examples
npm run start:js Run JavaScript examples
npm run start:ts Run TypeScript examples
npm run build Compile TypeScript
npm run build:lua Compile TypeScript to Lua

Logs

When running multiple services, logs are saved to:

  • logs/js-backend.log - JavaScript integration output
  • logs/ts-backend.log - TypeScript integration output

Resources

License

MIT License - Free to use for any purpose.