| Engine | LÖVE 11.x |
|---|---|
| Language | Lua 5.1 (LuaJIT) |
| Time to run | ~4 minutes |
| Level | Intermediate — comfortable with Lua tables and metatables |
| Output | One module (~140 lines) |
| Dependencies | None. |
The prompt
Open claude.ai/new, paste, send.
$ Build me a custom particle system module for LÖVE 11.x in pure Lua. // shape - A module returned via "return Particles" exposing: - Particles.new_emitter(opts) → emitter instance - emitter:emit(n) — spawn n particles - emitter:update(dt) - emitter:draw() // emitter options - position: { x, y } - lifetime: { min, max } seconds - speed: { min, max } pixels/sec - direction: { angle, spread } radians (angle = base direction, spread = +- random offset) - gravity: { x, y } pixels/sec^2 - size: { start, end } pixels (linearly interpolated over particle lifetime) - colors: { start, end } each = {r,g,b,a} (linearly interpolated) // behavior - update(dt) advances every particle: position by velocity * dt, velocity by gravity * dt, age by dt. Removes particles whose age > lifetime. - draw() iterates particles. For each: compute t = age / lifetime, lerp size and color, draw a love.graphics.rectangle("fill", ...) at the current position with the lerped size. // constraints - Pure Lua, no external libs. - No globals. Each emitter is independent. - Use love.graphics.setColor / love.graphics.rectangle. No SpriteBatches, no shaders. - Cap particles at 500 per emitter. Drop new emits if at cap. // return format - One file particles.lua in a code block. - Include a 12-line example showing a "coin pickup" sparkle effect from love.update. - No prose before or after.
Open in Claude ▸
Run · 4 min
What this gets you
"Game feel" without locking into a framework. Hit sparks, pickup glitter, dust on landing — all of these are five-line emitter configs with this module. Building your own gives you exactly the parameter set you need; LOVE's built-in ParticleSystem covers a different surface area and is more verbose for simple effects.
Quick checklist
- Color is lerped, not stepped. Look for math.lerp / linear interpolation on r, g, b, a separately.
- Velocity is in absolute units, not normalized. Setting speed = {min=20, max=80} and direction = {angle=0, spread=math.pi/4} should give particles moving rightward at 20-80 px/sec.
- Particles are removed in-place, not via table copy. A simple iterator-and-swap-with-end pattern. Don't allocate a new table every frame.
Full breakdown coming soon
The deeper writeup with worked examples (sparkle, dust, fire, sparks) and how to switch to image-based particles is on the roadmap. Bookmark this page.