Game State Format - snoopy-team/snoopy-server GitHub Wiki
Game State
The game state is a JSON object in the following format:
{
"sent": "2012-04-23T18:25:43.511Z",
"status": "ongoing",
"t": 2.3,
"players": {
"0": {
"position": [x, y],
"velocity": [vx, vy],
"acceleration": [ax, ay],
"orientation": angle,
"cooldown": s
},
"1": {
"position": [x, y],
"velocity": [vx, vy],
"acceleration": [ax, ay],
"orientation": angle,
"cooldown": s
},
...
}
"bullets": {
"0":[{
"position": [x, y],
"velocity": [vx, vy]]
},...]
"1":[{
"position": [x, y],
"velocity": [vx, vy]]
}, ...]
...
}
}
Meaning
sentdescribes the time at which the game state was sent to the frontendstatusdescribes whether the game is ongoing and, if not, who wontis the current game timeplayersis a dictionary mapping player IDs to game agents.bulletsis a dictionary mapping player IDs to lists of the bullets currently on screen fired by that player.
Types
The types of the individual fields is described below.
x, y: Coordinates
Individual matches will define a playing field (width, height), with both width and height some positive real number. Coordinates are (x, y), with 0 <= x <= width and 0 <= y <= height, in Cartesian coordinates: (0, 0) is the lower-right corner of the playing field. The correspondence between playing field and viewport is unspecified.
vx, vy, ax, ay: Vectors
These are also in Cartesian coordinates, in the same system as x and y, but unlike those these are signed. vx = -1 means the object is traveling 1 unit per game second to the left. ay = 1 implies that the object is accelerating upwards, not accounting for gravity, at 1 unit per game second per game second.
angle: Angle
Angles are in radians.
s: Game Seconds
s is in game seconds, which is not specifically correlated to real-world seconds. This is the unit of time in the physics engine.
sent: Timestamp
This describes the time the server sent the game state. It is in ISO 8601 format.
status: Status
This is right now just "ongoing" or "over", although in the future more detailed information might be included.
t: Game Time
This describes the moment in time that the state represents, in game seconds.