]> git.draconx.ca Git - rrace.git/blobdiff - src/motif_ui.c
Track elapsed time of the game.
[rrace.git] / src / motif_ui.c
index eca3e797605d5f42d910439144ac425782a31b4c..c31d8392ac7a828694128c2ec6e617a4faff9e85 100644 (file)
@@ -224,8 +224,18 @@ static void do_input_move(struct app_state *state, int x, int y)
                uint_least32_t mask;
 
                if (game_check_goal(&state->board)) {
-                       printf("You win!\n");
-                       game_finish(&state->board);
+                       int_fast32_t ms = game_finish(&state->board);
+                       unsigned min, sec;
+
+                       /* Negative time just means clock jumps and
+                        * display headaches. */
+                       if (ms < 0)
+                               ms = 0;
+
+                       sec = ms / 1000, ms %= 1000;
+                       min = sec / 60, sec %= 60;
+                       printf("You won!  Time was %u:%.2u:%.3u\n",
+                              min, sec, (unsigned)ms);
                }
 
                /* Figure out which tiles changed */