Easy Leaderboard for GameMaker

GameMaker
Leaderboards
Author image
Johannes Fornaeus5 min read
Cover image

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.

Foo

Implementing Easy Leaderboards can be done in 5 simple steps, which we'll explain more thoroughly below.

  1. Create a free LootLocker account
  2. Create a leaderboard
  3. Copy Game API key & leaderboardID
  4. Run InitializeLootLocker() from any Create event
  5. 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.

Foo

Once you've completed those steps, we need to enable the Guest Login authentication method so that players can be identified by your game.

  1. 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.

    1. 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.

    1. Replace "gameAPIkey" with the Game API key you copied from LootLocker as a string
    2. Replace "leaderboardID" with the leaderboardID(int) or key(string) that you copied from LootLocker
    3. Replace "version" with the version of your game, for example "0.0.0.1" as a string
    4. 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:

    1. Add Event -> Asynchronous -> Async - HTTP

    2. Insert the following code:

      LootLockerCallback();

    That's it - you're now ready to upload and display scores in your leaderboard in GameMaker!

    Now What?

    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:

    • LootLockerExample_SimpleLeaderboard
    • LootLockerExample_RockyRunner

    Below you can also find a variety of functions to make your leaderboard work in your game.

    Upload a score to your leaderboard:

    LootLockerSubmitScore("leaderboardID", “scoreYouWantToUpload”);
    

    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":

    LLHighscoresTopFormatted()
    

    Fetch the full list of centered highscores formatted as "1. PlayerName 1000":

    LLHighscoresCenteredFormatted()
    

    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!

    Stay up to date.

    Join our newsletter and get these posts sent directly to your inbox.