Games
A game is a directory, and everything about how it behaves lives inside it. The
client syncs the folder to your server,
and the server brings it to life. The game config sits at the
top level; the instance schema and its two
update files gather into a gamehoster-instance/ folder, the two player
schemas and their scripts into gamehoster-player/, alongside the
commands and entities
folders.
<gamehoster-config-contentRoot>/
game.gamehoster.org/ a domain
gamehoster-games/ your games live here
pong/ one game, one directory
gamehoster-game.json global game config
gamehoster-instance/ instance schema and its updates
gamehoster-player/ player schemas and their scripts
gamehoster-commands/ command handlers
gamehoster-entities/ entity types
asteroids/ another game
Contents
Each game folder holds a config file and four folders.
| Name | Type | Description |
|---|---|---|
gamehoster-game.json | file | The game's global config: title, tick and send rates, capacity. |
gamehoster-instance/ | directory | The instance's own state schema and its per-tick update scripts. |
gamehoster-player/ | directory | The player join and per-instance state schemas, and their scripts. |
gamehoster-commands/ | directory | The command handlers, one per command a player may send. |
gamehoster-entities/ | directory | The entity types the instance spawns. |
gamehoster-game.json
The game's basic global details.
{
"gamehoster-game-title": "Pong",
"gamehoster-game-browse": "none",
"gamehoster-game-create": "none",
"gamehoster-game-tickRate": 60,
"gamehoster-game-sendRate": 20,
"gamehoster-game-capacity": 2,
"gamehoster-game-timelineTicks": 128,
"gamehoster-game-displayDelay": 2,
"gamehoster-game-origins": "https://pong.example.com"
}
| Name | Type | Description |
|---|---|---|
gamehoster-game-title | string | The game's display name. Pong's is Pong. |
gamehoster-game-browse | string | What new players may browse on the frontend, via Gamehoster.Browse:
|
gamehoster-game-create | string | Whether players may create their own instances, via Gamehoster.Create:
|
gamehoster-game-tickRate | number | The simulation rate, on the server and every client. Pong steps at 60. One of the two clocks on Updates. |
gamehoster-game-sendRate | number | Packets per second to each player, the network rate. Pong sends at 20. |
gamehoster-game-capacity | number | The most players one instance holds. Pong seats 2. |
gamehoster-game-timelineTicks | number | How many past ticks of history the instance keeps in its timeline, so a late command can rewind to the tick it was made. |
gamehoster-game-displayDelay | number | How far behind the present, in ticks, the front end draws the world, so it eases toward known state instead of guessing. Your own player is always drawn at the present. |
gamehoster-game-origins | string / array | Optional. The web origin(s) allowed to open this game's socket; "*", or omitting the key, allows any. |