Creating a high score leaderboard

In many Scratch games, you want to create games that keep score and track high scores and rankings from one game to the next. In this article, I show you how to create a high score leaderboard for a game that will persist across sessions and display the rankings of the top three scores by name.

You can add this leaderboard to any game you have available. I'm going to use the Asteroid Blaster game that's included as one of the sample projects bundled with the Raspberry Pi version of Scratch [1]. I'm also going to incorporate the script from the "Stamping Numbers" article in the previous issue [2] that uses numbered costumes to display the score at the end of the game. Figure 1 shows the end result.

In Asteroid Blaster, the player has three lives to move a ship and shoot as many asteroids as possible. The player loses a life each time the ship collides with an asteroid. The game ends after the third collision. That's where I'm going to jump in and capture the scores to create a high score leaderboard. The game needs to track the top three scores, so each time the game ends, I need to check if the current score is higher than one of the top three scores. If the score is in the top three spots, I record the player's name and score.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Custom stamping game scores with costume numbers

    Add style to game score displays with stamp blocks and costumes.

  • Using graphical effects to distort a picture

    In this guessing game, graphic effects distort sprite costumes while the player tries to guess the animal shape. The game is creatively scored based on how much the shape is distorted.

  • Creating a multiplayer quick-reaction game

    The quick-reaction game provides an introduction to building simple circuits with the Raspberry Pi and controlling those circuits with ScratchGPIO, an advanced version of Scratch.

  • Synchronizing with broadcasts

    This article draws inspiration from the popular Pokémon Go app to recreate a sprite hunting game in Scratch. The project explores synchronization and randomness as the player explores various backdrops in search of sprites.

  • Power to You

    Small-board computers (SBCs) are getting more and more powerful. The Raspberry Pi 3 (RPi3), which just came out in February of this year, is a case in point. This latest in the Rasp Pi line now has four cores running at 1200MHz with 1GB of RAM and on-board WiFi and Bluetooth. If you need even more power in a small computer, however, you are not left wanting. In this issue, we look at three SBCs with more cores, more memory, more ports, and more possibilities.