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
A game directory inside a domain's gamehoster-games/ folder: a config file and four folders.

Contents

Each game folder holds a config file and four folders.

NameTypeDescription
gamehoster-game.jsonfileThe game's global config: title, tick and send rates, capacity.
gamehoster-instance/directoryThe instance's own state schema and its per-tick update scripts.
gamehoster-player/directoryThe player join and per-instance state schemas, and their scripts.
gamehoster-commands/directoryThe command handlers, one per command a player may send.
gamehoster-entities/directoryThe 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"
}
pong · gamehoster-game.json: everything else is instance state or in logic
NameTypeDescription
gamehoster-game-titlestringThe game's display name. Pong's is Pong.
gamehoster-game-browsestringWhat new players may browse on the frontend, via Gamehoster.Browse:
  • none: they are placed straight in.
  • instances: pick a live instance from a list, or create one.
gamehoster-game-createstringWhether players may create their own instances, via Gamehoster.Create:
  • none: they can't.
  • public: they can, and the new instance is listed for others to join.
  • password: they can, and it's listed, but joining needs a password they set.
  • private: they can, but the instance is unlisted, reached only by invite.
gamehoster-game-tickRatenumberThe simulation rate, on the server and every client. Pong steps at 60. One of the two clocks on Updates.
gamehoster-game-sendRatenumberPackets per second to each player, the network rate. Pong sends at 20.
gamehoster-game-capacitynumberThe most players one instance holds. Pong seats 2.
gamehoster-game-timelineTicksnumberHow 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-displayDelaynumberHow 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-originsstring / arrayOptional. The web origin(s) allowed to open this game's socket; "*", or omitting the key, allows any.