Say "good", "excellent" and "incredible" on long chain reactions.

This commit is contained in:
Jeremy Rand 2016-12-24 01:49:20 -05:00
parent 3d84abcc16
commit 1f24457a8a
3 changed files with 38 additions and 3 deletions

View File

@ -26,6 +26,10 @@
#define STARTING_GEMS_PER_POINT 3
#define MAX_GEMS_PER_POINT 20
#define SCORE_FOR_GOOD 9
#define SCORE_FOR_EXCELLENT 15
#define SCORE_FOR_INCREDIBLE 25
#define GEM_TYPE_AT_SQUARE(square) gGameState.squareStates[square].gemType
#define GEM_STARRED_AT_SQUARE(square) gGameState.squareStates[square].isStarred
@ -55,6 +59,10 @@ typedef struct tGameState {
static tGameState gGameState;
static tGameCallbacks *gGameCallbacks = NULL;
static tScore gPerMoveScore = 0;
static bool gSaidGood = false;
static bool gSaidExcellent = false;
static bool gSaidIncredible = false;
// Implementation
@ -72,6 +80,21 @@ static void incrementScore(void)
gGameCallbacks->scoreCallback(gGameState.score);
}
}
gPerMoveScore++;
if (gPerMoveScore > SCORE_FOR_INCREDIBLE) {
if (!gSaidIncredible) {
gSaidIncredible = gGameCallbacks->speakIncredible();
}
} else if (gPerMoveScore > SCORE_FOR_EXCELLENT) {
if (!gSaidExcellent) {
gSaidExcellent = gGameCallbacks->speakExcellent();
}
} else if (gPerMoveScore > SCORE_FOR_GOOD) {
if (!gSaidGood) {
gSaidGood = gGameCallbacks->speakGood();
}
}
}
@ -691,6 +714,11 @@ bool moveSquareInDir(tSquare square, tDirection dir)
return true;
}
gPerMoveScore = 0;
gSaidGood = false;
gSaidExcellent = false;
gSaidIncredible = false;
gGameCallbacks->beginClearGemAnim();
if (actOnMatchAtSquare(square, false))
goodMove = true;
@ -701,7 +729,6 @@ bool moveSquareInDir(tSquare square, tDirection dir)
if (!goodMove) {
doSwapSquares(square, otherSquare, true);
} else {
while (explodeGems())
;
@ -769,4 +796,4 @@ bool loadGame(void)
deleteGame();
return true;
}
}

View File

@ -50,6 +50,10 @@ typedef struct tGameCallbacks {
void (*dropSquareFromTo)(tSquare srcSquare, tSquare tgtSquare, tGemType gemType, bool starred);
void (*dropSquareFromOffscreen)(tSquare tgtSquare, tGemType gemType, bool starred);
void (*endDropAnim)(void);
bool (*speakGood)(void);
bool (*speakExcellent)(void);
bool (*speakIncredible)(void);
} tGameCallbacks;

View File

@ -76,7 +76,11 @@ static tGameCallbacks gCallbacks = {
beginDropAnim,
dropSquareFromTo,
dropSquareFromOffscreen,
endDropAnim
endDropAnim,
speakGood,
speakExcellent,
speakIncredible
};