mirror of
https://github.com/IllusionMan1212/cudoku.git
synced 2026-10-24 02:12:25 +00:00
fix: reset game timer on state reset and don't zero timers when stopping them
This commit is contained in:
@@ -289,6 +289,7 @@ void reset_state(Cudoku *game) {
|
|||||||
game->should_draw_selection = false;
|
game->should_draw_selection = false;
|
||||||
game->should_highlight_mistakes = false;
|
game->should_highlight_mistakes = false;
|
||||||
game->has_won = false;
|
game->has_won = false;
|
||||||
|
timer_reset(&game->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_win(Cudoku *game) {
|
bool check_win(Cudoku *game) {
|
||||||
@@ -564,8 +565,6 @@ void generate_random_board(Cudoku *game) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove_numbers(game);
|
remove_numbers(game);
|
||||||
|
|
||||||
timer_reset(&game->timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_board(Cudoku *game) {
|
void reset_board(Cudoku *game) {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ float timer_remaining(Timer *timer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void timer_stop(Timer *timer) {
|
void timer_stop(Timer *timer) {
|
||||||
timer->time = 0.0f;
|
|
||||||
timer->is_running = false;
|
timer->is_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
extern struct timeval start_time;
|
extern struct timeval start_time;
|
||||||
|
|
||||||
typedef struct Timer {
|
typedef struct Timer {
|
||||||
@@ -11,7 +12,6 @@ typedef struct Timer {
|
|||||||
bool is_running;
|
bool is_running;
|
||||||
} Timer;
|
} Timer;
|
||||||
|
|
||||||
|
|
||||||
double get_time();
|
double get_time();
|
||||||
void start_internal_timer();
|
void start_internal_timer();
|
||||||
bool timer_ended(Timer *timer);
|
bool timer_ended(Timer *timer);
|
||||||
|
|||||||
Reference in New Issue
Block a user