Game Architecture
Bigger project needs better architecture
What is a good architecture?
A good architecture…
• Is easy to understand & maintain
• Welcomes changes
• Maximizes code reuse, minimizes duplication
Why does VTT need a good architecture?
Big game (dev-wise)
• Online tower defense, card collection on mobile
Big game (dev-wise)
• > 500 characters w/ different upgrade strategies
Big game (dev-wise)
• > 500 characters w/ different upgrade strategies
Big game (dev-wise)
• > 500 characters w/ different upgrade strategies
Big game (dev-wise)
• > 500 characters w/ different upgrade strategies
Big game (dev-wise)
• Complex items system: equip, enhance, forge
Big game (dev-wise)
• Complex items system: equip, enhance, forge
Big game (dev-wise)
• Complex items system: equip, enhance, forge
Big game (dev-wise)
• 8 game modes for the 500 characters to perform
Big game (dev-wise)
• 8 game modes for the 500 characters to perform
Big game (dev-wise)
• 8 game modes for the 500 characters to perform
Big game (dev-wise)
• 8 game modes for the 500 characters to perform
Big game (dev-wise)
• 8 game modes for the 500 characters to perform
Big game (dev-wise)
• 8 game modes for the 500 characters to perform
Game data & config need to be human-friendly and easy to change
• Game designers & operators are lazy human beings
Anh Cody ơi giảm base dam,
tăng máu cho Thạch Sanh hộ
em
Tự vào admin panel chỉnh đê!!!
Short on time, while requirements change fast
• Reuse as much as possible
• Adapt to change
What is the most suitable architecture for VTT?
OOP?
• Easy to understand
• Suitable for small project
Game objects usually share common (set of) functionalities
Bird Collision, Graphics, Animation, TouchHandling
Pipe Collision, Graphics, Movement
Ground Collision, Graphics, Movement
Inheritance
Collidable
(Collision)
Pipe Checkpoint
Renderable
Animatable
(Animation)
Bird
Movable
(Movement)
Pipe Ground
Inheritance
Collidable
(Collision)
Pipe Checkpoint
Renderable
Animatable
(Animation)
Bird
Movable
(Movement)
Pipe Ground
Mixins or Multiple-inheritance. No!!!
Bird Pipe Ground
Collidable
(Collision) Renderable
Animatable
(Animation)
Movable
(Movement)
Pipe Checkpoint
Base Game Object
It’s hard to create a good OO architecture for bigger & more
complicated games
• Impossible to build a good OOP class hierachy
• Where to put logic code that process objects of 2+
different classes?
• Easy to make mistake when working in team
Component-based entity system
Component-based Entity System
• A hot topics in recent years
• Unity3D is an example
Component-based Entity System
• Multitude of ways to
represent & implement
Component-based Entity System
3 components:
• Entity
• Component
• System
Entities – Components
Graphics Anim Move Along Path
Attack Skill Collection Bonus
Officer (defend) x x x x x
Officer (run) x x x
Soldier (defend) x x x
Soldier (run) x x x
Animal x x x
• Decompose game entities by capabilities into reusable components
– Components contains only data
– Each entity has an unique ID and a list of components
• Create entities by picking the desired components
Systems
• Divide game aspects into systems
• Systems process only entities they care about in each game loop
Move Along Path Sys
Animation Sys
Collection Bonus Sys Attack Sys Skill Sys
Officer (defend)
Officer (run) Soldier
(defend) Soldier (run) Animal
Entities – Components - Systems
Artemis Entity System
• An open-source Entity System Framework originally
written in Java
• Ported to many languages
Benefits
Goes hand-in-hand with Data-Driven Methodology
• Components are just data, separated from game logic. Entities are just
bag of components
– Can be stored & retrieved from anywhere
– Human can make changes easily
MongoDB as database
• Flexible data structure, welcomes changes
• Easy synchronization between client / backend
Easy synchronization between client / backend
Easy synchronization between client / backend
Promote multi-threading
• Systems are independent from one another
-> can be run in separate threads
Conclusions
Online Game + Entity System = WIN
References
• A Data-Driven Game Object System
http://scottbilas.com/files/2002/gdc_san_jose/game_objects_slides.ppt
• Entity Systems are the future of MMOG development
http://t-machine.org/index.php/2007/11/11/entity-systems-are-the-
future-of-mmog-development-part-2/
• Evolve Your Hierarchy
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/
• http://gamedev.stackexchange.com/a/31491
THANK YOU!
Top Related