Easy Leaderboard for GameMaker
We've released an extension for GameMaker that makes it super easy to add online leaderboards to your game: we call it Easy Leaderboard by LootLocker!
In addition to the extension, we've also created a sample game called Rocky Runner that demonstrates the leaderboards in action.
Implementing Easy Leaderboards can be done in 5 simple steps, which we'll explain more thoroughly below.
- Create a free LootLocker account
- Create a leaderboard
- Copy Game API key & leaderboardID
- Run InitializeLootLocker() from any Create event
- Run LootLockerCallback() from Async - HTTP event
That's it - it's that easy!
Here are each of those steps in more detail.
Create a free LootLocker account
It takes less than a minute to sign up and get started with LootLocker, so what are you waiting for? Head right over the LootLocker to sign up now for free and follow the guide below.
Once you've completed those steps, we need to enable the Guest Login authentication method so that players can be identified by your game.
- Click on the cog wheel on the sidebar:
- Next, click on Platforms:
- Scroll down and select Guest Login:
- Enable guest login by clicking the toggle in the top right corner. Then press Save:
Now we have our LootLocker settings just how we want them and can continue setting up our leaderboard.
Create a leaderboard in LootLocker
Now that you've signed up and configured LootLocker, it's time to create a leaderboard for your game.
- In the LootLocker dashboard, click the Systems icon in the sidebar, and then Leaderboards:
- Click Create:
- Give your leaderboard a name and key, the name is what you use inside the LootLocker dashboard, the key is what you can use as an identifier in your game. Check “Enable Game API writes”, and click Save:
Great, now we've created the leaderboard in LootLocker and can begin implementing it in GameMaker!
Copy the Game API key & leaderboardID
We'll now want to copy the Game API key and leaderboardID from the LootLocker console into GameMaker.
The Game API key can be found in the Settings menu by clicking the cog wheel in the sidebar and selecting Game Settings. It will be under the “API” tab.
The leaderboardID can be found by clicking on Systems and selecting Leaderboards. You should see the ID of the leaderboard you created earlier, you can also use the key that you put in earlier to identify the leaderboard.
Run InitializeLootLocker() from any Create event
Inside GameMaker, create a new Object. In the Create event, insert the following code:
LootLockerInitialize("gameAPIkey", "version", "developmentMode", "leaderboardID");
If you’re using GML Visual, you’ll need to add the “Execute Code” action and enter the code inside it.
Next we will replace the variables that we just entered with real data.
- Replace "gameAPIkey" with the Game API key you copied from LootLocker as a string
- Replace "leaderboardID" with the leaderboardID(int) or key(string) that you copied from LootLocker
- Replace "version" with the version of your game, for example "0.0.0.1" as a string
- Replace "developmentMode" with boolean true or false (depending on which environment you created the leaderboard in in LootLocker)
Run LootLockerCallback() from the Async - HTTP event
Now we want to create a new Async - HTTP event. We can do this selecting:
Add Event -> Asynchronous -> Async - HTTP
Insert the following code:
That's it - you're now ready to upload and display scores in your leaderboard in GameMaker!
Now that you've set up our Easy Leaderboard in GameMaker, it's time to hook it up to your game.
Included in the extension are two examples we created for different ways to implement the leaderboard:
Below you can also find a variety of functions to make your leaderboard work in your game.
Upload a score to your leaderboard:
As mentioned previously, you can use the Key defined for a leaderboard in place of its ID. Both ways are valid.
Fetch the full list of high scores formatted as "1. PlayerName 1000":
Fetch the full list of centered highscores formatted as "1. PlayerName 1000":
There are lots of more functions available in the extension if you want to dive deeper into leaderboard functionality that you can find in our User Documentation. If you get stuck or need any help, join us on Discord and we'll do our best to help out.
Good luck and have fun!