Game Development Reference
In-Depth Information
public void HandleInput(InputHelper inputHelper)
{
if (inputHelper.MouseLeftButtonPressed() && !shooting)
{
shooting = true ;
velocity = (inputHelper.MousePosition
position) 1.2f;
ballShot.Play();
}
}
Similarly, we also play a sound when a paint can of the correct color falls out of the
screen.
11.4 Maintaining a Score
Scores are often a very effective way of motivating players to continue playing.
Especially highscores work very well in that regard, because they introduce a com-
petitive factor into the game: you want to be better than 'AAA' or 'XYZ'. 1 In the
Painter game, we add a member variable score to the GameWorld class to store the
current score in. This member variable is of type int , and it is given an initial value
of 0 in the constructor method:
score = 0;
We also add a property to the GameWorld class, so that game objects can update the
score when needed:
public int Score
{
get { return score; }
set { score = value ;}
}
The player starts with a score of zero. Each time a paint can falls outside of the
screen, the score is updated. If a can of the correct color falls out of the screen,
10 points are added to the score. If a can does not have the right color, the player
loses a life.
The score is a part of what we call the economy of a game. The economy of
a game basically describes the different costs and merits in a game and how they
interact. When you make your own game, it is always useful to think about its econ-
omy. What do things cost, and what are the gains of executing different actions as a
player? And are these two things in balance with each other?
1 A lot of early arcade games allowed only three characters for each name in the high score list,
leading to a lot of very imaginative names.
Search WWH ::




Custom Search