A visually appealing space shooter game built with Lua and the LOVE2D framework, demonstrating procedural graphics, particle effects, and game state management.
- Quick Start
- Prerequisites
- Installation
- Running the Game
- Game Controls
- Project Structure
- TypeScript/JavaScript Integration
- Extending the Game
Step 1: Install Dependencies
For learners, use the automated installation script:
macOS/Linux:
./install.shWindows:
install.batThe script will guide you through installing all required dependencies.
Step 2: Start the Project
Launch the game and/or integration examples:
macOS/Linux:
./start.shWindows:
start.batThe start script provides an interactive menu to:
- Run the LOVE2D game (frontend)
- Run JavaScript integration examples (backend)
- Run TypeScript integration examples (backend)
- Run game with backend services
- Run all services simultaneously
macOS (Homebrew):
brew install lovemacOS (Manual):
- Download from https://love2d.org/
- Move LOVE.app to Applications folder
- Add to PATH:
alias love="/Applications/love.app/Contents/MacOS/love"
Windows:
- Download installer from https://love2d.org/
- Run installer
- LOVE2D will be available in your PATH
Linux (Ubuntu/Debian):
sudo apt install loveLinux (Arch):
sudo pacman -S love# Clone or download this project
cd lua-example
# Verify LOVE2D installation
love --versionOption 1: Using the start script (Recommended)
# macOS/Linux
./start.sh
# Windows
start.batOption 2: Manual start
# From the project directory
love .
# Or specify the full path
love /path/to/lua-example| 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 |
lua-example/
├── install.sh # Automated setup script (macOS/Linux)
├── install.bat # Automated setup script (Windows)
├── start.sh # Start script with menu (macOS/Linux)
├── start.bat # Start script with menu (Windows)
├── main.lua # Main game logic (WITH SPRITE SUPPORT)
├── conf.lua # LOVE2D configuration
├── IMPLEMENTED_SPRITES.md # How your sprites are integrated
├── YOUR_SPRITES.md # Quick sprite reference
├── assets/ # Game assets (images, sounds, fonts)
│ └── README.txt # Asset loading guide
├── logs/ # Backend service logs
├── README.md # This file
└── integration/ # TypeScript/JavaScript examples
├── lua-bridge.ts
├── lua-runner.js
├── tstl-game.ts
├── package.json
├── tsconfig.json
├── tsconfig.tstl.json
└── types/ # TypeScript type declarations
├── fengari.d.ts
├── fengari-interop.d.ts
└── README.md
The game now uses custom sprites:
- 4 player ship variations
- 23 enemy ship types
- 11 background images
See YOUR_SPRITES.md for quick reference or IMPLEMENTED_SPRITES.md for full details.
There are several ways to integrate Lua with TypeScript/JavaScript:
Fengari is a Lua 5.3 implementation in JavaScript that runs in browsers and Node.js.
cd integration
npm install
npm run exampleTranspile TypeScript directly to Lua code for use in LOVE2D.
npm install -g typescript-to-lua
tstl --project tsconfig.jsonBundle LOVE2D with Electron for desktop distribution with web technologies.
High-performance Lua 5.4 via WebAssembly.
npm install wasmoonSee the integration/ folder for complete examples.
The game currently uses procedural graphics (shapes drawn with code), but you can easily add sprite images for the spaceship, bullets, and enemies.
See ADDING_IMAGES.md for a complete step-by-step guide on:
- Where to place image files
- How to load images in Lua
- How to modify the game to use sprites
- Where to find free game assets
- Example code with image fallbacks
Quick example:
-- In love.load()
local spaceship = love.graphics.newImage("assets/spaceship.png")
-- In love.draw()
love.graphics.draw(spaceship, x, y)A ready-to-use version with image support is available in main-with-images.lua.
In main.lua, modify the spawnEnemy() function:
local enemyTypes = {
-- Add new enemy type
{
width = 80,
height = 40,
speed = 50,
color = {0.2, 0.8, 0.2},
health = 5,
points = 500
}
}- Create a
powerupstable - Add spawn logic in
love.update - Check collision with player
- Apply effects (speed boost, multi-shot, shield)
-- In love.load()
local sounds = {
shoot = love.audio.newSource("assets/shoot.ogg", "static"),
explosion = love.audio.newSource("assets/explosion.ogg", "static")
}
-- When shooting
sounds.shoot:clone():play()-- In love.load()
local music = love.audio.newSource("assets/music.ogg", "stream")
music:setLooping(true)
music:play()- Glow Effects: Multiple semi-transparent layers drawn at increasing sizes
- Particle Systems: Explosion particles with velocity, decay, and color
- Parallax Scrolling: Stars at different speeds for depth perception
- Procedural Shapes: Ships and enemies drawn with polygons, not sprites
- Color Theming: Consistent color schemes for visual cohesion
- Use
love.graphics.newCanvas()for pre-rendering static elements - Batch similar draw calls together
- Use sprite sheets instead of individual images
- Pool objects instead of creating/destroying frequently
- Use
love.graphics.SpriteBatchfor many similar sprites
MIT License - Feel free to use this code for any purpose.