We usually use Phaser to create HTML5 games.
You can start by cloning https://github.com/WonkyStar/nzk-game-starter
By doing so, you will start with:
You can look up what data is available by using tools such as GraphiQL to get the schema of our graphql server.
The endpoint is: https://graphql.nightzookeeper.com/graphql
Each game will be served through an iframe and launched with the following query parameter:
animalId
: Unique identifier of the animal that the kid chose for playing.So the game is responsible of getting that parameter and fetching the correct animal.
You can fetch an animal by using a query like the following.
query getAnimal($animalId: String!) {me {_idanimal(_id: $animalId) {_idnameartwork {url}}}}
During development phase, you might want to get a random animal or the first one to avoid having the query parameter everytime. You can get the first animal by querying something like this:
query getAnimals {me {_idanimals(skip: 0, limit: 1) {_idnameartwork {url}}}}
This will get the animal, its name and artworkUrl.
NOTE: You have to be authenticated to query the current user (me). If you're using the starter provided above, you shouldn't have any problems. If you are not, please refer to Authentication for instructions on how to authenticate and make authenticated queries.
You can use the following mutation to save a score entry
input ScoreInput {gameId: String!score: Intanimal: String}extend type Mutation {saveScore(input: ScoreInput): Score}
*NOTE: You have to be authenticated to save your score and the animal provided for the score entry should belong to the authenticated user.