added timers to auto-hide help and for counting the time it took to solve the puzzle

This commit is contained in:
2023-11-17 06:16:32 +02:00
parent be4df6685c
commit 77435c5095
10 changed files with 241 additions and 47 deletions
+19 -3
View File
@@ -2,7 +2,9 @@
#include <stdbool.h>
#include "helper.h"
#include "shader.h"
#include "timer.h"
typedef struct Vec2 {
int x;
@@ -22,6 +24,9 @@ typedef struct Cudoku {
bool should_draw_selection;
bool should_highlight_mistakes;
bool should_draw_help;
Timer help_timer;
Timer timer;
float win_time;
} Cudoku;
typedef struct Color {
@@ -37,7 +42,7 @@ void draw_bg_grid_shader(Shader shader, unsigned int vao, float* transform, floa
void draw_bg_grid_texture(Shader shader, unsigned int vao, unsigned int texture, float* transform);
void draw_numbers(Shader shader, unsigned int vao, unsigned int vbo, float *transform, Cell board[9][9]);
unsigned int prepare_win_overlay();
void draw_win_overlay(Shader win_shader, Shader font_shader, unsigned int vao, unsigned int font_vao, unsigned int font_vbo, float *transform);
void draw_win_overlay(Shader win_shader, Shader font_shader, unsigned int vao, unsigned int font_vao, unsigned int font_vbo, float *transform, Cudoku *game);
void prepare_selection_box(unsigned int *vao, unsigned int *vbo);
void draw_selection_box(Shader shader, unsigned int vao, unsigned int vbo, int x, int y, float *transform, Color color);
void highlight_mistakes(Shader shader, unsigned int vao, unsigned vbo, float *transform, Cudoku *game);
@@ -48,5 +53,16 @@ void move_selection(Cudoku *game, int x, int y);
void toggle_selection(Cudoku *game);
void generate_random_board(Cudoku *game);
void reset_board(Cudoku *game);
void toggle_help(Cudoku *game);
void draw_help_overlay();
bool toggle_help(Cudoku *game);
void draw_help_overlay(
Shader overlay_shader,
Shader font_shader,
unsigned int overlay_vao,
unsigned int overlay_vbo,
unsigned int font_vao,
unsigned int font_vbo,
Matrix4x4 *projection,
int window_height,
Timer *timer
);
void draw_timer(Shader shader, unsigned int vao, unsigned int vbo, float *projection, Timer *timer, int win_width);