You can either add the zeros directly to the list's stage monitor or use the add (0) to (Leaderboard Scores) block. This ensures that the score evaluations later in the script will work. I choose to add a zero to each of the first three items when I create the Leaderboard Scores list. The Leaderboard Scores list needs to contain a number in each of the first three list items, or the evaluation that checks whether the score is greater than the current value will not work with a non-number, the check will always evaluate to false and no player will ever be able to enter a high score. The script requires two lists, Leaderboard Names and Leaderboard Scores, that are used to capture the leaders and their high scores. The clear block removes the stamped score from the screen.įigure 3: Finding and displaying top-three scores. I've also updated all the other scripts in the existing game to start on this broadcast message. The reason I'm using a Play Game broadcast instead of the usual when clicked block is because the player will have an option to restart the game. As you can see, you need to create and hide three variables named High Score 1, High Score 2, and High Score 3. Figure 2 shows the sprite's initialization script starting with the when I receive(Play Game) block. I'm adding all my leaderboard scripts to a new sprite called Score, which will include costumes representing numbers, as I discussed in the previous article. Then I'll prompt the player to play another game. To finish the programming, I want to display the current player's score and, after the top scores are evaluated, the top three high scores. If the score is in the top three spots, I record the player's name and score. 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. That's where I'm going to jump in and capture the scores to create a high score leaderboard. The player loses a life each time the ship collides with an asteroid. In Asteroid Blaster, the player has three lives to move a ship and shoot as many asteroids as possible.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |