I'm making the game Boggle in C for a project. If you're not familiar with Boggle, that's okay. Long story short, there's a time limit on each round. I'm making the time limit 1 minute.
I have a loop that displays the game board and asks the user to enter a word, then calls a function that checks to see if the word is accepted, and then it loops back again.
while (board == 1)
{
if (board == 1)
{
printf(display gameboard here);
printf("Points: %d Time left: \n", player1[Counter1].score);
printf("Enter word: ");
scanf("%15s", wordGuess);
pts = checkWord(board, wordGuess);
The while (board == 1)
needs to be changed so that it loops only for 1 minute.
I want the user to only be able to do this for 1 minute. I also would like for the time to be displayed where I have Time left: in the printf
statement. How would I achieve that? I've seen some examples online of others using a timer in C and the only way I'm thinking this is possible is if I let the user go past the time limit but when the user tries to enter a word past the time limit, it will notify them that time is up. Is there any other way?
EDIT: I'm coding this on a Windows 10 PC.