New impressive streak animation

This commit is contained in:
2017-05-25 17:46:51 +02:00
parent dd28f75813
commit 6c168a8618
2 changed files with 30 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ int main(int argc, char **argv) {
gs->guesses = 0;
gs->trollEnabled = 0;
hf->besthit = 0;
hf->impstreakcounter = 0;
keypad(stdscr, FALSE);
nonl(); //No new line. Prevents the new line when hitting enter
@@ -265,6 +266,7 @@ int playerInput(game_state *gs, hitfeed *hf) {
//gs->moves++;
gs->guesses++;
trollHitScreen(gs, hf, found);
trollHandleImpressive(hf, gs, found); //Prints a message with a little animation
}
} else {
/* no valid character found */
@@ -464,6 +466,30 @@ void printHitFeed(game_state *gs, hitfeed *hf) {
}
}
void trollHandleImpressive(hitfeed *hf, game_state *gs, int hits) {
if (hits >= IMPRESSIVEHIT) {
hf->impstreakcounter++; //Increase the counter
} else {
/* There was a hit beneath the hit threshold.
The streak is vanished */
hf->impstreakcounter = 0;
}
if (gs->trollEnabled && hf->impstreakcounter >= IMPRESSIVESTREAK) {
/* Execute animation and reset the counter */
int i;
for (i = 0; i < 5; i++) {
mvprintw(5, gs->centerx - 5, "IMPRESSIVE!");
refresh();
usleep(100000);
mvprintw(5, gs->centerx - 5, " ");
refresh();
usleep(100000);
}
hf->impstreakcounter = 0;
}
}
void drawFigure(game_state *gs, int drawNext) {