49
Component-based Entity System in Mobile Game Development Cody Nguyen ([email protected])

OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

  • Upload
    ogdc

  • View
    258

  • Download
    4

Embed Size (px)

Citation preview

Page 1: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Component-based Entity System

in Mobile Game Development

Cody Nguyen ([email protected])

Page 2: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen
Page 3: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Game Architecture

Page 4: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen
Page 5: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Bigger project needs better architecture

Page 6: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen
Page 7: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

What is a good architecture?

Page 8: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

A good architecture…

• Is easy to understand & maintain

• Welcomes changes

• Maximizes code reuse, minimizes duplication

Page 9: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Why does VTT need a good architecture?

Page 10: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• Online tower defense, card collection on mobile

Page 11: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• > 500 characters w/ different upgrade strategies

Page 12: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• > 500 characters w/ different upgrade strategies

Page 13: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• > 500 characters w/ different upgrade strategies

Page 14: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• > 500 characters w/ different upgrade strategies

Page 15: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• Complex items system: equip, enhance, forge

Page 16: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• Complex items system: equip, enhance, forge

Page 17: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• Complex items system: equip, enhance, forge

Page 18: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• 8 game modes for the 500 characters to perform

Page 19: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• 8 game modes for the 500 characters to perform

Page 20: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• 8 game modes for the 500 characters to perform

Page 21: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• 8 game modes for the 500 characters to perform

Page 22: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• 8 game modes for the 500 characters to perform

Page 23: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Big game (dev-wise)

• 8 game modes for the 500 characters to perform

Page 24: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

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 đê!!!

Page 25: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Short on time, while requirements change fast

• Reuse as much as possible

• Adapt to change

Page 26: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

What is the most suitable architecture for VTT?

Page 27: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

OOP?

• Easy to understand

• Suitable for small project

Page 28: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Game objects usually share common (set of) functionalities

Bird Collision, Graphics, Animation, TouchHandling

Pipe Collision, Graphics, Movement

Ground Collision, Graphics, Movement

Page 29: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Inheritance

Collidable

(Collision)

Pipe Checkpoint

Renderable

Animatable

(Animation)

Bird

Movable

(Movement)

Pipe Ground

Page 30: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Inheritance

Collidable

(Collision)

Pipe Checkpoint

Renderable

Animatable

(Animation)

Bird

Movable

(Movement)

Pipe Ground

Page 31: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Mixins or Multiple-inheritance. No!!!

Bird Pipe Ground

Collidable

(Collision) Renderable

Animatable

(Animation)

Movable

(Movement)

Pipe Checkpoint

Base Game Object

Page 32: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

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

Page 33: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Component-based entity system

Page 34: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Component-based Entity System

• A hot topics in recent years

• Unity3D is an example

Page 35: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Component-based Entity System

• Multitude of ways to

represent & implement

Page 36: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Component-based Entity System

3 components:

• Entity

• Component

• System

Page 37: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

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

Page 38: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

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

Page 39: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Entities – Components - Systems

Page 40: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Artemis Entity System

• An open-source Entity System Framework originally

written in Java

• Ported to many languages

Page 41: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Benefits

Page 42: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

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

Page 43: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

MongoDB as database

• Flexible data structure, welcomes changes

• Easy synchronization between client / backend

Page 44: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Easy synchronization between client / backend

Page 45: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Easy synchronization between client / backend

Page 46: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Promote multi-threading

• Systems are independent from one another

-> can be run in separate threads

Page 47: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

Conclusions

Online Game + Entity System = WIN

Page 48: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

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

Page 49: OGDC 2014_Entity system in mobile game development_Mr. Cody nguyen

THANK YOU!