This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
World State
Alexandru Dan edited this page Aug 29, 2017
·
6 revisions
The world state class servers as a gateway/buffer between the updates generated in different parts of the back-end and the data emitted by the socket.
It contains all the parameters that need to be sent to the client every time the world is updated. These are:
- Player (aka avatars) creation, deletion and update.
- Changes in map features, i.e. creation and deletion of:
- Health points
- Score points
- Pickups
- Obstacles
Rather than sending the whole state of the world each time, we only send updates of the current world of the state.
A typical initial state sent by the server may look like:
[
"world-update",
{
"map_features":{
"pickup":{
"create":[
],
"delete":[
]
},
"obstacle":{
"create":[
{
"y":4,
"x":4,
"id":3713084879516988331
},
{
"y":5,
"x":2,
"id":3713082714461575706
},
[...]
{
"y":2,
"x":5,
"id":3713085962047400956
}
],
"delete":[
]
},
"health_point":{
"create":[
],
"delete":[
]
},
"score_point":{
"create":[
],
"delete":[
]
}
},
"players":{
"create":[
{
"y":2,
"x":-5,
"score":0,
"health":5,
"id":1
}
],
"update":[
],
"delete":[
]
}
}
]
Each avatar has its own personalized view of the world, this feature being implemented in pull request...