Games
A game is a directory, and everything about how it behaves lives inside it. The
local tool 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
gamehoster-bots/ optional: server-side bots
gamehoster-frontend/ optional: client-side rendering and input
asteroids/ another game
Contents
Each game folder holds a config file, the four definition folders, and two optional folders: server-side bots and the client-only front end.
| 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-bots/ | directory | Optional. Server-side bots that pad an instance and play as ordinary players. |
gamehoster-frontend/ | directory | Optional. The client-only front end: the render loop, per-event input and lifecycle snippets the browser runs. See Frontend. |
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-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 | How new players reach an instance, applied by the join body:
|
gamehoster-game-create | string | Whether players may create their own instances, and how a new one is listed:
|
gamehoster-game-tickRate | number | The simulation rate, on the server, the only simulator. Pong steps at 60. One of the two clocks on the tick. |
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-botRate | number | Optional. Times per second the bot pass runs โ population control and each bot's brain. Defaults to 10; irrelevant to a game with no bots. |
gamehoster-game-warmInstances | number | Optional. How many instances the engine keeps alive at all times, humans present or not, so the game is always running and pre-warmed with bots. Defaults to 0 (instances open purely on demand). Asteroids sets 1, so there is always a live arena to drop into and to monitor. |
gamehoster-game-origins | string / array | Optional. The web origin(s) allowed to open this game's socket; "*", or omitting the key, allows any. |