2023-09-03 00:51:45 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
2023-09-08 16:38:14 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
2023-11-17 06:16:32 +02:00
|
|
|
#include "helper.h"
|
2023-09-03 00:51:45 +03:00
|
|
|
#include "shader.h"
|
2023-11-17 06:16:32 +02:00
|
|
|
#include "timer.h"
|
2023-11-21 02:52:15 +02:00
|
|
|
#include "ui.h"
|
2023-09-12 23:32:58 +02:00
|
|
|
|
2023-09-15 23:47:43 +02:00
|
|
|
typedef struct Cell {
|
|
|
|
|
int value;
|
|
|
|
|
bool is_locked;
|
|
|
|
|
} Cell;
|
|
|
|
|
|
2023-09-12 23:32:58 +02:00
|
|
|
typedef struct Cudoku {
|
2023-09-15 23:47:43 +02:00
|
|
|
Cell board[9][9];
|
2023-09-14 01:41:39 +02:00
|
|
|
int solution[9][9];
|
2023-09-12 23:32:58 +02:00
|
|
|
bool has_won;
|
|
|
|
|
Vec2 selection;
|
|
|
|
|
bool should_draw_selection;
|
2023-10-02 03:24:58 +02:00
|
|
|
bool should_highlight_mistakes;
|
2023-10-02 23:59:48 +02:00
|
|
|
bool should_draw_help;
|
2023-11-17 06:16:32 +02:00
|
|
|
Timer help_timer;
|
|
|
|
|
Timer timer;
|
|
|
|
|
float win_time;
|
2023-09-12 23:32:58 +02:00
|
|
|
} Cudoku;
|
|
|
|
|
|
2023-09-08 16:38:14 +02:00
|
|
|
void set_scale_factor(int width, int height, float *x, float *y);
|
2023-09-12 03:21:18 +02:00
|
|
|
unsigned int prepare_bg(bool use_texture, unsigned int *texture);
|
|
|
|
|
void draw_bg_grid_shader(Shader shader, unsigned int vao, float* transform, float resolution);
|
|
|
|
|
void draw_bg_grid_texture(Shader shader, unsigned int vao, unsigned int texture, float* transform);
|
2023-09-15 23:47:43 +02:00
|
|
|
void draw_numbers(Shader shader, unsigned int vao, unsigned int vbo, float *transform, Cell board[9][9]);
|
2023-11-17 06:16:32 +02:00
|
|
|
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);
|
2023-09-12 23:32:58 +02:00
|
|
|
void prepare_selection_box(unsigned int *vao, unsigned int *vbo);
|
2023-10-02 03:24:58 +02:00
|
|
|
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);
|
|
|
|
|
void toggle_check(Cudoku *game);
|
2023-09-12 23:32:58 +02:00
|
|
|
void do_selection(Cudoku *game, int x, int y, int width, int height, float x_scale, float y_scale);
|
|
|
|
|
void set_selected_number(Cudoku *game, int number);
|
|
|
|
|
void move_selection(Cudoku *game, int x, int y);
|
|
|
|
|
void toggle_selection(Cudoku *game);
|
2023-09-14 01:41:39 +02:00
|
|
|
void generate_random_board(Cudoku *game);
|
2023-10-02 03:24:58 +02:00
|
|
|
void reset_board(Cudoku *game);
|
2023-11-17 06:16:32 +02:00
|
|
|
bool toggle_help(Cudoku *game);
|
2023-11-26 21:32:19 +02:00
|
|
|
void draw_help(Timer *timer);
|
2023-11-26 05:34:42 +02:00
|
|
|
void draw_timer(Timer *timer);
|
2023-11-26 03:58:40 +02:00
|
|
|
void draw_win(Cudoku *game);
|
2023-11-26 21:32:19 +02:00
|
|
|
void draw_board(Cudoku *game, Size window_size);
|