Game Development Reference
In-Depth Information
Chapter 18
Finishing the Game
18.1 Introduction
In this chapter, we will finish the game
Jewel Jam
. As a first step, we are going to
give the player extra points when he/she makes two or three valid combinations of
three jewels at the same time. Secondly, we are going to add a nice visual effect by
showing glitters on the jewels in the game. Finally, we will add sound and music to
the game.
18.2 Extra Points for Multiple Combinations
We want to give the player extra points when the player finds multiple combinations
at once. Because a column contains 10 different jewels, the player can make at most
three combinations of three jewels at once. So, we award the player extra points in
case of two or three multiple combinations. In order to do that, we have to count how
many combinations a player finds. We do this in the
JewelGrid
class, by introducing
an extra variable
nrCombis
:
int
nrCombis = 0;
Every time we find a valid combination, we increment this variable. Now we can
check with an
if
-instruction when we should award extra points:
if
(nrCombis == 2)
{
score.Score += 50;
}
else if
(nrCombis == 3)
{
score.Score += 100;
}