Page 1
Brewing Your Brewing Your Own Game Own Game
EngineEngineThe Pros & Cons of Using Open Source Software to The Pros & Cons of Using Open Source Software to
Rapidly Develop Cross-platform Indie Games and ToolsRapidly Develop Cross-platform Indie Games and ToolsYe Feng
Page 2
What’s In The Talk
No rocket science
From practical experience
Arguable
Page 4
Project OneTap
One One ButtonButton
2D Action2D Action
Simple Simple PuzzlePuzzle
CasualCasual
CustomizabCustomizable Levelsle Levels
Page 5
Challenge:Level Design
Page 6
Wise Man Builds His House On The
Rock
Option 1: Cheap Commercial Engine
Option 2: Open Source Engine
Page 7
Cheap Commercial Engine
Pros
IDE
Cross platform(when officially supported)
Moderate license fee
Cons
Offline IDE
Portability(when not officially supported)
No source code
Pure script driven
Page 8
Open Source Engine
Pros
Source code
Cross platform
Free
Cons
No IDE
Pure native code driven
Open Source License
Page 9
Choice
Option 1: Cheap Commercial Engine
Option 2: Open Source Engine
Option 3: Open Source Engine + Game Support Layer
Allegro
http://alleg.sourceforge.net/
✔
Page 11
What’s In ItGame Object System
Script Integration
Physics Integration
Content pipeline tools
Others
Simple Scene Management
Action System
Script Key-Value Dictionary
etc...
Page 12
Game Object System
Page 13
Inheritance & Gameplay
Development
Gameplay dev nature: iteration
Iteration causes changes
Inheritance: not change-friendly
Page 21
Design Pattern
Favor object composition over class inheritance
Page 22
Game Object & Game Component
Composition instead of inheritance
A object of gameplay logic
Is composed by multiple functional components
Game Game ObjectObject
Component Component #1#1
Component #2Component #2
Component #3Component #3
Page 23
Game Object & Game Component
Add/remove component in runtime
Key to build an IDE
Page 24
Composition To The Rescue
Page 25
Basic ComponentsPositioning info: Transform
2D rendering: Sprite
Bitmap info: Bitmap Source
Input processing: Event Receiver
Rigid body entity: Body
Collider entity: Fixture
Particle effect: Particle Emitter
etc...
Page 26
User Components
Arbitrary stuff that gameplay needs
Rotation forever
A goal in level
The behavior of characters
A spike need to be avoided
Line drawer needed by editor
etc...
Page 28
Script Integration
Page 29
Dilemma of Native
Compilation time
Runtime modification
Advanced language feature
“Glue” code
Page 30
2-tiers System To The Rescue
Core: native code
Editor and gameplay: script
Lua
Page 31
Related Works
Communication between native and script
Export tools/libraries
Script API
Page 32
Communication - Native & Script
Simple interfaces/engine API
tolua
http://www.tecgraf.puc-rio.br/~celes/tolua/
Simple, no compilation cost
Complex interfaces
Lua C API
Page 33
Related Works cont.
Serialization
Load/save, editor
Support for advanced features
Reference
Function object, closure
etc...
Page 34
Serialization
Pluto
https://github.com/hoelzro/pluto
Write serialization code for every component
1000 lines of Lua code
Page 35
Prefabricated Object
Take snapshot of object
Parameters
References
Hierarchy
Assisted object design
Level editor ➔ object editor
Page 36
Patching
Patching binary ➔ patching data
Page 38
Content Pipeline Tools
Page 40
StaticStatic
AnimationAnimation
Pipeline
FlashFlash
PhotoshoPhotoshopp
ExporExportt ManuallManuall
y y Created Created
AtlasAtlas
IDEIDE
GameGame
☹
Page 41
Solution
swfdec
Open source Flash player
LGPL
swfdec-dumper
Surface ➔ disk
https://github.com/fengye/swfdec-dumper
Page 42
Pipeline 2.0
StaticStatic
AnimationAnimation
FlashFlash
PhotoshoPhotoshopp
IDEIDE
GameGame
swfdec swfdec dumpedumpe
rr ManuallManually y
Created Created AtlasAtlas
☹☺
Page 43
Atlas Tool
Stitch bitmap into Atlas
Automation
Transparent process
Page 44
Texture Atlas Gen
nVidia Texture Atlas Tools
File format support☺
Mipmap☺
Free☺
Only for sprite sheets☹
Pack algorithm
Page 45
Pipeline 3.0
StaticStatic
AnimationAnimation
FlashFlash
PhotoshoPhotoshopp
IDEIDE
GameGame
swfdec swfdec dumpedumpe
rr Texture Texture Atlas Atlas GenGen
☺☺