Home › LÖVE (Love2D) › LÖVE (Love2D) Lua game rules

LÖVE (Love2D) Lua game rules

Cursor rules for 2D games with LÖVE 11.5 in Lua: callbacks, modules, delta time, asset loading, and performance.

CursorLÖVE (Love2D)

How to use

Save this as .cursor/rules/love2d.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.cursor/rules/love2d.mdcDownload  
---
description: LÖVE (Love2D) Lua game conventions
globs: ["**/*.lua"]
alwaysApply: false
---

# LÖVE (Love2D 11.5)

- `main.lua` only defines `love.load`, `love.update(dt)`, `love.draw`, and input callbacks, delegating to a scene/state manager in `src/`.
- Modules return a table: `local Player = {}; Player.__index = Player; function Player.new(x, y) ... end; return Player`. Everything `local`; no accidental globals (enable a strict mode or run `luacheck`).
- Multiply all movement and timers by `dt`. Use a fixed-step accumulator for physics-sensitive logic.
- Load images, fonts, sounds, and shaders once in `love.load` or a scene's `enter` and cache them in an `assets` module. Never call `love.graphics.newImage`/`newFont` inside `update`/`draw`.
- Pixel art: `love.graphics.setDefaultFilter("nearest", "nearest")` before loading images; draw to a canvas at native resolution and scale it.
- Batch many identical sprites with `SpriteBatch` and texture atlases (`Quad`s).
- Reset graphics state you change (`love.graphics.push()`/`pop()`, `setColor(1,1,1,1)`). Colors are 0-1, not 0-255.
- Use `love.physics` (Box2D) only when real physics is needed; otherwise simple AABB checks.
- Save data with `love.filesystem` (writes to the save directory), serialized as JSON or Lua tables.
- Configure window and modules in `conf.lua`.

## Done when
`luacheck src main.lua` reports no warnings and the game runs with `love .` without errors in the console.

More: all LÖVE (Love2D) rules · all Cursor rules

Related rules

Godot 4 C# rules

Cursor rules for Godot 4.x games written in C# (.NET 8): node scripts, signals, exports, and performance.

CursorGodot

Roblox Luau rules

Cursor rules for Roblox experiences in Luau: strict typing, client/server boundaries, remotes, and data saving.

CursorRoblox (Luau)

Three.js rules

Cursor rules for Three.js (r17x, ES modules) web 3D and games: render loop, disposal, assets, and performance.

CursorThree.js

Unity C# game dev rules

Cursor rules for Unity 6 projects in C#: performance, MonoBehaviour lifecycle, ScriptableObjects.

CursorUnity (C#)

Unity DOTS / ECS rules

Cursor rules for Unity Entities 1.x (DOTS): baking, ISystem with Burst, jobs, IJobEntity, and structural changes.

CursorUnity (C#)

Unreal Engine 5 C++ gameplay rules

Cursor rules for Unreal Engine 5 gameplay C++: UObject reflection, TObjectPtr, Enhanced Input, components, and Blueprint APIs.

CursorUnreal Engine (C++)

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.