Added simple animation to hit message

This commit is contained in:
2017-05-03 20:04:58 +02:00
parent fbf1d10af1
commit d220ade335

View File

@@ -33,6 +33,7 @@ int main(int argc, char **argv) {
gs->moves = 0;
gs->guesses = 0;
gs->trollEnabled = 0;
keypad(stdscr, FALSE);
curs_set(0);
while ( (c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1 ) {
@@ -172,28 +173,29 @@ void drawGuessWord(game_state *gs) {
}
int playerInput(game_state *gs) {
char inp;
int inp;
int i, found = 0;
inp = getch();
for (i = 0; i < gs->wordLength; i++) {
if (inp == gs->guessWord[i]) {
found++;
//break;
if (inp != KEY_UP && inp != KEY_DOWN && inp != KEY_LEFT && inp != KEY_RIGHT) {
for (i = 0; i < gs->wordLength; i++) {
if (inp == gs->guessWord[i]) {
found++;
//break;
}
}
}
if (found) {
/* found a valid character */
if (fillCurrentWord(gs, inp)) {
//gs->moves++;
gs->guesses++;
trollHitScreen(gs, found);
}
} else {
/* no valid character found */
if (stackWrongCharacter(gs, inp)) {
gs->moves++;
gs->guesses++;
if (found) {
/* found a valid character */
if (fillCurrentWord(gs, inp)) {
//gs->moves++;
gs->guesses++;
trollHitScreen(gs, found);
}
} else {
/* no valid character found */
if (stackWrongCharacter(gs, inp)) {
gs->moves++;
gs->guesses++;
}
}
}
return 0;
@@ -298,7 +300,7 @@ void trollHitScreen(game_state *gs, int hits) {
"Ultra Hit", "Monster Hit", "Rampage", \
"Unstoppable", "Wicked sick", "Godlike"};
int selection[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int i, len, z, found = 0;
int i, found = 0;
for (i = 0; i < 9; i++) {
if (selection[i] == hits) {
found = 1;
@@ -310,10 +312,15 @@ void trollHitScreen(game_state *gs, int hits) {
mvprintw(5, centerDiff(gs->centerx, strings[i]), strings[i]);
refresh();
/* sleep and vanish */
usleep(500000);
len = strlen(strings[i]);
for (z = centerDiff(gs->centerx, strings[i]); z < gs->centerx + len; z++) {
mvprintw(5, z, " ");
int j = 0, k = gs->maxx - 1;
for (j = 0; j < gs->centerx; j++, k--) {
mvprintw(5, j, "!");
mvprintw(5, k, "!");
refresh();
usleep(8000);
mvprintw(5, j, " ");
mvprintw(5, k, " ");
}
}
}