Added start screen; Cursor enabled on Word input

This commit is contained in:
2017-05-01 20:15:30 +02:00
parent bedd8b4127
commit 6df0af4c2f
2 changed files with 16 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
#include "hangman.h"
#include <stdlib.h> //atexit
#include <string.h>
#include <ctype.h>
#include <ctype.h> //tolower
int main(void) {
/* Initialization */
@@ -14,8 +14,11 @@ int main(void) {
gs->allowedMoves = DEFAULTTRIES;
gs->moves = 0;
gs->guesses = 0;
curs_set(0);
/* Show the start screen */
curs_set(0);
showStartScreen(gs);
/* start game */
initGuessWord(gs);
noecho(); /* Don't show the player input */
@@ -32,6 +35,14 @@ void quitProgram(void) {
endwin();
}
void showStartScreen(game_state *gs) {
mvprintw(gs->centery - 1, gs->centerx - 15, "Welcome to hangman in ncurses.");
mvprintw(gs->centery, gs->centerx - 5, "Have fun!");
mvprintw(gs->centery + 1, gs->centerx - 17, "https://gitlab.com/STRUCTiX/hangman");
refresh();
getch();
clear();
}
void updateScreen(game_state *gs) {
mvprintw(1, 1, "Remaining wrong guesses: %i", (gs->allowedMoves - gs->moves));
@@ -50,7 +61,9 @@ void initCoordinates(game_state *gs) {
void initGuessWord(game_state *gs) {
int i;
mvprintw(1, 1, "Please enter your word: ");
curs_set(1);
getstr(gs->guessWord);
curs_set(0);
toLowerCase(gs->guessWord);
gs->wordLength = strlen(gs->guessWord);
for (i = 0; i < gs->wordLength; i++) {