O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Simple Game Animation

With these preliminaries out of the way, we’re ready to tackle an actual problem that a typical Lua hacker might face. Lua is often used as a scripting language for games. These days, games often include particle systems that generate organic-looking graphical effects. I’ve always wanted to build a particle emitter, so today I’m going to start a fire, functional style!

A functional particle system wouldn’t retain mutable state, so it might be a function that accepts state (particles) as an argument and produces new state (new particles).

But before I can start writing my particle system, I need something capable of drawing. I was without my computer this weekend, so that gave me an excuse to use Codea,[34] a cute ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required