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

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.

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-bots/directoryOptional. Server-side bots that pad an instance and play as ordinary players.
gamehoster-frontend/directoryOptional. 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"
}
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-browsestringHow new players reach an instance, applied by the join body:
  • 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, and how a new one is listed:
  • 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, the only simulator. Pong steps at 60. One of the two clocks on the tick.
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-botRatenumberOptional. 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-warmInstancesnumberOptional. 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-originsstring / arrayOptional. The web origin(s) allowed to open this game's socket; "*", or omitting the key, allows any.