Entities
The non-player things. Snake has two
entity types: the tail and the food.
Both are static. They appear and disappear but never move, so neither carries an update script. A
snake's body is a run of tail cells laid where the head has been, and food sits on the grid until a
snake eats it. Each type holds just a schema.
<gamehoster-config-contentRoot>/
game.gamehoster.org/
gamehoster-games/
snake/
gamehoster-entities/
tail/
gamehoster-entity-schema.json
food/
gamehoster-entity-schema.json
Contents
One folder per entity type; each holds a single schema and no update, because snake entities never move.
| Name | Type | Description |
|---|---|---|
tail/gamehoster-entity-schema.json | file | One body cell of a snake. |
food/gamehoster-entity-schema.json | file | A piece of food on the grid. |
tail/gamehoster-entity-schema.json
One body cell of a snake. Every field is public, the
position x, y and the color, so every viewer who can see the
cell draws it; the grid coordinates carry min/max range hints. The cell's
server-only bookkeeping is not in the schema: owner (which player the cell belongs to)
and seq (the incrementing stamp saying how old the cell is, so the oldest expires first
as the snake moves) live in the tail's Entity.Persistent
bag, which is never streamed.
[
{
"gamehoster-entity-schema-name": "x",
"gamehoster-entity-schema-type": "int",
"gamehoster-entity-schema-default": 0,
"gamehoster-entity-schema-visibility": "public",
"gamehoster-entity-schema-min": 0,
"gamehoster-entity-schema-max": 120
},
{
"gamehoster-entity-schema-name": "y",
"gamehoster-entity-schema-type": "int",
"gamehoster-entity-schema-default": 0,
"gamehoster-entity-schema-visibility": "public",
"gamehoster-entity-schema-min": 0,
"gamehoster-entity-schema-max": 80
},
{
"gamehoster-entity-schema-name": "color",
"gamehoster-entity-schema-type": "string",
"gamehoster-entity-schema-default": "",
"gamehoster-entity-schema-visibility": "public"
}
]
food/gamehoster-entity-schema.json
A piece of food on the grid. Its only fields are the position x, y, both
public, so every viewer draws it. Food has no colour and no
owner. The server keeps the food topped up to a target and places more when a snake dies.
[
{
"gamehoster-entity-schema-name": "x",
"gamehoster-entity-schema-type": "int",
"gamehoster-entity-schema-default": 0,
"gamehoster-entity-schema-visibility": "public",
"gamehoster-entity-schema-min": 0,
"gamehoster-entity-schema-max": 120
},
{
"gamehoster-entity-schema-name": "y",
"gamehoster-entity-schema-type": "int",
"gamehoster-entity-schema-default": 0,
"gamehoster-entity-schema-visibility": "public",
"gamehoster-entity-schema-min": 0,
"gamehoster-entity-schema-max": 80
}
]