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