Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Designing a Component-based Architecture in Lua for Game Apps

Jheng Wei Ciao
January 14, 2013
2.1k

Designing a Component-based Architecture in Lua for Game Apps

Jheng Wei Ciao

January 14, 2013
Tweet

Transcript

  1. Pitfalls in IBA Deep and tangled hierarchies Diamond ring inheritance

    Copy-paste code here and there Special cases “Warning: don’t touch this!”
  2. Component-based Architecture Each functionality is a game component Data-driven method

    for objects creation Design Patterns: “Favor composition over inheritance” Game Engine: Unity 3D
  3. Drawbacks in Lua Most editors don’t support auto-completion code Goodbye

    to debuggers & breakpoints Hello to loggers & print() No excuse for coffee break time
  4. Don’t use CBA... yet CBA can’t save the (your) world

    OOD can do good things too Don’t make everything a component Leave messy code alone You might need an editor or tool
  5. Pitfalls in Lua Naming convention for global variables Do garbage

    collection manually Don’t forget to compile scripts & strip debug info
  6. My Lua Trilogy Lua 5.1.5 Luabind 0.9.1 Time-saver & OO-like

    Boost Luabind depends: template programming
  7. My Programming Trilogy C++ Generic framework Objective-C iOS platform-specific OpenGL

    ES implementation Lua Data description Game logic 10% 65% 25% C++ Lua Objectitve-C
  8. Traditional OOP Game Objects Update #1 #2 #3 #4 #5

    Game Objects Render #1 #2 #3 #4 #5
  9. If you are into Lua... Step 1) Data description/serialization Step

    2) User interface Step 3) Game logic Warning: Don’t use Lua for everything