What's a good adventure game without a score? Scores are an essential part of any game. This chapter will teach you how to handle them.
Scores are very easy to handle with SCI. The score bar and score variables are all set up in the main script.
First you need to open the main script. Open the game and the
Game Explorer will load.
|Next, click on the script folder and the list of scripts in your game will appear on the right, along with a preview of the first script.|
|Scroll down the list until you see the "Main" script. Double click on it, and the script editor will open up with it.|
Setting Up The Score
The score revolves around two global variables: gScore and gMaxScore.
If you scroll down the list of global variables (main's local variable block), you will find the score variables.
These are the score variables. The gScore variable contains the current score. The gScore variable contains the game's maximum score. Finally, when you add to the player's score, the previous score is stored in gOldScore.
To set the game's maximum score, simply change gMaxScore's value from 0 to whatever your game's score will be.
Updating The Score
Updating the score is incredibly simple. You just make a call to the game class' changeScore() method.
Adds 3 to the score. If gScore was 5, for example, it would now be 8.
Customizing the Score Bar
You naturally won't want your game's score bar to say "Template Quest". This being the case, you can change it easily by scrolling down to the StatusCode instance and change the text in the Format() kernel call.
That sums up the scores! In the next chapter, you will learn about using the death handler!