This documentation explains how to build Hydra profile support into an existing game. As our example, we’ll be working with a very simple “game” called Masher, written in Python, which prompts the user for their name, reads lines of input one at a time, and adds up the number of characters the user has entered.
The original version of the game stores the user’s name, rounds played, and count of characters typed in a data structure which is saved to a file on disk using Python’s pickle module. Our goal is to modify this game to store the player’s data in Hydra instead.
We will be making HTTP requests to Hydra’s REST API for reading and writing player data, but before we get started, we need to do some setup (for the purposes of this documentation, it’s assumed we already have a Hydra account). We need three things:
- A project
- An environment
- An API key
Projects correspond to game titles. Environments belong to projects, and serve as containers for different groups of players (e.g. players on different platforms for a multi-platform game; in the case of Masher, one environment will suffice). An API key will grant us access to read from and write to the environment we set up.
TODO: describe UX for creating project/environment/API key in dashboard
We won’t be doing away entirely with the filesystem in our demo game; the change will be that the file we write to disk will store only the player’s Hydra ID, rather than their actual stats. The player’s name and counts of rounds played and characters typed will be saved to Hydra.