Featured Blog

Designing a Component-based Architecture in Lua for Game Apps

This is the talk I presented in 2012 Game Game App Developers Conference Taipei in Taiwan. I’d like to share my passion for Lua and talk about some techniques we used in Jade Ninja and Bonnie’s Brunch 2.

Hi there, I'm Wei Ciao. Before becoming an iOS developer, I was a game programmer working for a company making MMO genre games. My primary skills and fondness in programming languages are C++ and Lua. As a game developer, I’ve dug deeply in Lua and developed a game framework based on it.

Here is the combination of programming languages utilized in my game apps:

  • C++: General abstract framework can be used in cross-platforms.
  • Objective-C: Handling iOS platform-specific details and OpenGL ES implementation.
  • Lua: Data description. User interfaces. Game logic. Anything else.

With Lua, I can easily describe a game object simply based on components. In the example above, the game object, Player, is composed of 3 components, which are:

  • Transform: In charge of translation, rotation and scaling in game world.
  • Quad: A simple quad drawn in 2D plane to represent the object.
  • BoundingBox: Collision detecting in box-shaped.


One object can comprise several components, however, not every component needs to be updated and/or rendered. Unlike traditional object-oriented architecture, in component-based architecture we can update and render the game objects accordingly.

What we called a game object, actually is nothing more than a container. Game object doesn’t need to be involved in how specific game components function. It merely contains and manages them in an abstract way and all tasks are assigned to its components. Powers are delegated to the game components.

For example, when a game object consists of Interpolator game component, we can interpolate a variable between the starting value and the ending value, and then apply it to image alpha or scaling. Interpolator will make your objects and interfaces look bouncing and vivid if used properly.

As for memory management, Lua takes no responsibility. All dynamically memory-allocated objects are created in C++ and passed-by-reference for Lua to utilize. Lua only gets pointers. Lua could perform complex memory management tasks, but a clear separation between C++ and Lua helps making memory management less error-prone.

Lua is lightweight, robust and cross-platform. Programming in Lua can save you a lot of compile-time for source files, and the coding process has a quick turnover rate. The higher turnover rate is, the more iterations you can get. In the process of game development, more iterations help increasing work efficiency and improving game quality.

If you are wondering how it works in game apps, you may check out my latest game Bonnie's Brunch 2 and upcoming Jade Ninja.

Live well, happy coding and make great games!  :D

Download full slides

Introduction to Component Based Architecture in Games 

(The article has been posted originally on Monkey Potion dev blog)

 Follow me on @MonkeyPotion

Latest Jobs


Vancouver, BC, Canada

Bladework games

Remote (United States)
Senior Gameplay Engineer

University of Canterbury

Christchurch, Canterbury, New Zealand
Academic in Game Arts and Animation

Fred Rogers Productions

Hybrid (424 South 27th Street, Pittsburgh, PA, USA
Producer - Games & Websites
More Jobs   


Explore the
Advertise with
Follow us

Game Developer Job Board

Game Developer


Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Advertise with

Game Developer

Engage game professionals and drive sales using an array of Game Developer media solutions to meet your objectives.

Learn More
Follow us


Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more