X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=word-game.c;h=76c67205d1f5922b086b2de1ef11a24f6504440a;hb=0a8d1f741a919c9c7e5ae0b8d0261759cca9bc05;hp=2b9fa4e1e3df481096778425c9a1092a9d06b41c;hpb=76c92c2f9f062d3bc3cbbf57416fe6b23f1d114b;p=wordgame diff --git a/word-game.c b/word-game.c index 2b9fa4e..76c6720 100644 --- a/word-game.c +++ b/word-game.c @@ -112,11 +112,17 @@ word_game_play (const char *puzzle, sprintf (prompt, "> "); remaining = 1; } - do { + while (1) { if (time_limit_seconds) { - minutes = remaining / 60; - seconds = remaining % 60; - sprintf (prompt, "%02d:%02d ", minutes, seconds); + if (remaining > 0) { + minutes = remaining / 60; + seconds = remaining % 60; + sprintf (prompt, "%02d:%02d ", minutes, seconds); + } else { + printf ("Time's up.\a\n"); + sprintf (prompt, "> "); + time_limit_seconds = 0; + } } response = readline (prompt); if (response == NULL) @@ -157,7 +163,7 @@ word_game_play (const char *puzzle, remaining = floor (0.5 + (tv_stop.tv_sec - tv.tv_sec) + (tv_stop.tv_usec - tv.tv_usec) / 1000000.0); minutes = remaining / 60; } - } while (remaining > 0); + } printf ("\n%s\n", puzzle);