light cycles galore building a multi-server multiplayer game architecture by per lohmann

19
Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Upload: joan-bailey

Post on 05-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Light Cycles Galore

Building a Multi-Server Multiplayer Game Architecture

By

Per Lohmann

Page 2: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Light Cycles the game• Inspired by the movie Tron• Similar to the game Snake• Players drive around in a world controlling a

Light Cycle• Each Light Cycle leave a tail after it

Page 3: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Early design decisions• Game is 2D• Moves are either Up, Down, Left or Right• World split into zones of fixed sizes• Each zone is handled by a server• No loading screen between zone transitions• Visibility into other zones

Page 4: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

System architecture

Page 5: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Master server consequences• Single point of failure/limitation

– Can be a bottleneck

• Single point of connection– Easy server setup– Client connection is simplified

Page 6: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Implementation• Master server project

– WinForm application

• Server project– WinForm application

• Game Client project– XNA 2.0

• Common project– Containing shared objects and enums (mostly

concerning network communication)

Page 7: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Representing the world (server)• Zones are rectangular

– Size set by the master server– Layout set by the master server– References to nearest eight world directions

• North, Northeast, East, Southeast etc.

– Represented as a two dimensional array• Each element represents a player id• Id = 0 is reserved for empty space• Id = 1 is reserved for walls

Page 8: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Collision detection• Collision detection in constant time O(k)

– Lookup in array at a specified position

Page 9: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Representing the world (Client)• “Unlimited” size of game world• No loading between zones• Visibility into other zones• Not practical with an array representation• List of list of tiles (tiles are equivalent to player

id’s)– Do not use structs when using lists in C#!

Page 10: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Representing the world (Client)

Page 11: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Client view• Clients view is larger than the actual viewed part

on the screen– Buffer area allowing the client to receive view updates

before they are visible (buffer = one seconds movement)

Page 12: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Game state communication• Client sends information when performing an

action• Server sends information when updates about

players view occur

• Dead reckoning / Client side prediction– http://www.gamasutra.com/features/19970919/aronson_01.htm

Page 13: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Zone transitions• Two types of server states

– Active server– Passive server

• When clients view enters another servers area the active server informs the client to connect to a passive server

• Client sends commands to all “registered” servers

• Receives updates respectively– Will not work in a FPS game– Would work in World of Warcraft

Page 14: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Architecture scalability• Currently Master server uses TCP

– One TCP connection per server– One TCP connection per client– ≈ 60.000 free ports

• Server / client communication uses UDP– No real restrictions except bandwidth and server

resources

Page 15: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

The end

Questions?

Page 16: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Server “crash”• Detecting server “crashes”

– TCP connection to Master server gets torn down– Any servers without zones get assigned that zone– All data from zone is lost but “world” continues– MS could inform players of server crash (currently it

does not)

Page 17: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Transmitting data TCP• TCP (Reliable, Connection oriented, etc.)

– Encode/decode using built in binary converter– TCP is stream based and not message based– Multiple encoded objects received– TCP wrapper object appending object length

Page 18: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann

Transmitting data UDP• UDP (unreliable)

– Uses pure unreliable UDP– Encode/decode using own implementations– Highly efficient– Byte shifting– Could be done more easily using C (memcpy)

Page 19: Light Cycles Galore Building a Multi-Server Multiplayer Game Architecture By Per Lohmann