protocol object update - Squarific/Game-Of-Everything GitHub Wiki

  • Encoding: UTF-8
  • Parsing: JSON
  • Description:

We create a protocol for object update. To use this optimally you should also adhere to the object creation protocol.

  • How to use:

We send an object every time a object updates. We will give an example for movement.

The object contains the property type which is a string with the constant value "update".

It should also contain the property ID which is a random string that identifies your object.

The position property is an object, it can have an x, y or z property for one of the dimensions. They are ints/floats of your position in units. Most often pixels. When a dimension isn't there it should remain unchanged. Dimensions should always be initialized at 0.

This speed is measured in units/ms where units most often are pixels. It should have the same dimensions as your position. If someone does not have the speed property set or didn't specify one of the dimensions it should be interpreted as a speed of 0.

Rotation is the direction in which an object looks as a direction vector.

  • Example:

{"type: "update", "id": "MYRANDOMID", "position": {"x": 500, "y": 429}, "speed": {"x": 0.2, "y": 0.3}, "rotation": {x: "1", y: "2", z": "180"}}