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.
That's it - it's that easy!
Here are each of those steps in more detail.
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.
Now we have our LootLocker settings just how we want them and can continue setting up our leaderboard.
Now that you've signed up and configured LootLocker, it's time to create a leaderboard for your game.
Great, now we've created the leaderboard in LootLocker and can begin implementing it in GameMaker!
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.
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.
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!