ServerDataFormat - JeffWaltzer/yet-another-space-war GitHub Wiki
Server to client
The protocol is a series of JSON objects. The top level object consists of an array of polygon objects, under the key "polygons" and an array of two integers describing the screen size, under the name "field_size", like this:
{
"polygons" : [...]
"field_size" : [1024, 1024]
}
The field size is simply the logical width and height of the playfield; all coordinates are in this system.
Each polygon consists of 1 or more wireframe objects, a score object, and a position objects. The score is a simple integer, and the position is the x,y coordinates of the polygon.
The wireframe(s) consist of a color, which is a string, and an array of x-y coordinates. The screen object is drawn using those points and the specified color.
Client to server
The protocol for client commands is simple strings, one per line. The commands are:
- fire
- thrust_on
- thrust_off
- clone
- rotate_right
- rotate_left
- rotate_stop