diff --git a/a2bejwld/game.c b/a2bejwld/game.c index e9167d2..410837c 100644 --- a/a2bejwld/game.c +++ b/a2bejwld/game.c @@ -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; -} \ No newline at end of file +} diff --git a/a2bejwld/game.h b/a2bejwld/game.h index 76a77b4..9d8c652 100644 --- a/a2bejwld/game.h +++ b/a2bejwld/game.h @@ -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; diff --git a/a2bejwld/ui.c b/a2bejwld/ui.c index 18f8c8e..913ec62 100644 --- a/a2bejwld/ui.c +++ b/a2bejwld/ui.c @@ -76,7 +76,11 @@ static tGameCallbacks gCallbacks = { beginDropAnim, dropSquareFromTo, dropSquareFromOffscreen, - endDropAnim + endDropAnim, + + speakGood, + speakExcellent, + speakIncredible };