Fixed game stats screen #20
This commit is contained in:
19
hangman.c
19
hangman.c
@@ -223,6 +223,7 @@ void drawGuessWord(game_state *gs) {
|
|||||||
}
|
}
|
||||||
rows++;
|
rows++;
|
||||||
}
|
}
|
||||||
|
gs->wordRows = rows; //set the number of rows for clearing the screen later
|
||||||
tempstartpos = xcounter = gs->centerx - (gs->wordLength / rows);
|
tempstartpos = xcounter = gs->centerx - (gs->wordLength / rows);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -327,13 +328,14 @@ int checkWin(game_state *gs) {
|
|||||||
|
|
||||||
void printGameStats(game_state *gs) {
|
void printGameStats(game_state *gs) {
|
||||||
//clear();
|
//clear();
|
||||||
int i;
|
int i, z;
|
||||||
double diff;
|
double diff;
|
||||||
diff = difftime(gs->endTime, gs->startTime);
|
diff = difftime(gs->endTime, gs->startTime);
|
||||||
|
for (z = 0; z <= gs->wordRows; z++) { //<= takes the last row too
|
||||||
for (i = 0; i < gs->maxx; i++) {
|
for (i = 0; i < gs->maxx; i++) {
|
||||||
mvprintw(gs->centery, i, " ");
|
mvprintw(gs->centery + z, i, " ");
|
||||||
mvprintw(gs->centery + 1, i, " ");
|
//mvprintw(gs->centery + 1, i, " ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gs->moves >= gs->allowedMoves) {
|
if (gs->moves >= gs->allowedMoves) {
|
||||||
mvprintw(gs->centery, gs->centerx - 10, "Game lost. Solution:");
|
mvprintw(gs->centery, gs->centerx - 10, "Game lost. Solution:");
|
||||||
@@ -447,3 +449,12 @@ void drawFigure(game_state *gs, int drawNext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void lala(void) {
|
||||||
|
int c;
|
||||||
|
if ((c = getch()) == 10) {
|
||||||
|
c *= 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
/* Defined macros */
|
/* Defined macros */
|
||||||
#define DEFAULTTRIES 6
|
#define DEFAULTTRIES 6
|
||||||
#define MAXWORDLENGTH 100
|
#define MAXWORDLENGTH 200
|
||||||
#define ALPHABET 26
|
#define ALPHABET 26
|
||||||
#define ALPHABET_NUM 36
|
#define ALPHABET_NUM 36
|
||||||
#define ANIM_DURATION 1
|
#define ANIM_DURATION 1
|
||||||
@@ -28,6 +28,7 @@ typedef struct {
|
|||||||
char *alphabet;
|
char *alphabet;
|
||||||
time_t startTime;
|
time_t startTime;
|
||||||
time_t endTime;
|
time_t endTime;
|
||||||
|
int wordRows;
|
||||||
} game_state;
|
} game_state;
|
||||||
|
|
||||||
typedef struct word {
|
typedef struct word {
|
||||||
|
Reference in New Issue
Block a user