Leaderboards and Tournaments Tutorial - Setup
The focus of this tutorial is the Leaderboards and Tournanaments integration into an Android game. We use the Kotlin language in our code, but all concepts apply equally to Java. We will stick to standard Android framework classes such as Activities and AsyncTasks.
Because our focus is the integration of Leaderboards and Tournanaments into a game, we use a very simple quiz game. The code for this game is provided in whole without integration, and then we go through each integration point. The entire game is provided for download. The tar-ball is a git repository. There is a separate branch for each step in this tutorial. This approach allows us to see how each API integration impacts the app as a whole.
Before starting the Leaderboards and Tournanaments integration, we need to complete the following prerequistes.
- Android Studio (with all of its dependencies such as Java) setup.
- A test device or emulator to run the app.
- A registered account with Leaderboards and Tournanaments, with the accompanying API key. If you haven't already registered, go here to set up your account.
- After you register with Leaderboards and Tournanaments, you'll need to create a game. This will give you an admin API key. We need this in our app later.
- For our sample game, we use one long-lived tournament to collect scores. Using the admin console, create a new tournament and have it expire after a few weeks or months. After creating the tournament, you can copy the tournament id from the URL in the Leaderboards and Tournanaments console. It will be a standard GUID, for example
- To avoid implementing all of the HTTP client boilerplate by hand, we use the openapi-codegen tool with the Player API model to generate the client code.
- Download the game source code.