Skip to main content

Actor state layout

Actor state is a base64-encoded binary blob (up to 96 bytes). This tutorial uses the first 17 bytes.

Byte layout

BytesTypeField
0–7float64 LEworldX (pixels)
8–15float64 LEworldY (pixels)
16uint8Push bitfield (see below)
17–95Reserved / unused

Push bitfield (byte 16)

BitValueMeaning
01Pushing north (dot at top edge)
12Pushing south
24Pushing east
38Pushing west

Multiple bits may be set (corner push).

Encode example

const buf = new ArrayBuffer(96);
const view = new DataView(buf);
view.setFloat64(0, worldX, true);
view.setFloat64(8, worldY, true);
view.setUint8(16, pushFlags);
return btoa(String.fromCharCode(...new Uint8Array(buf)));

See ActorUpdateRequestInput and sendActorUpdate.