-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
64 lines (53 loc) · 1.94 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//#include "board.c"
#include "mgui.h"
#include "raylib.h"
#include "board.h"
//#include <raylib.h>
//#define RAYGUI_IMPLEMENTATION
//#include "raygui.h"
int main() {
int board_choice;
int screen_width = 1600;
int screen_height = 800;
InitWindow(screen_width, screen_height, "Lelles minesweeper magi :D");
SetTargetFPS(24);
SetTraceLogLevel(LOG_ERROR);
int prompt_size = 1;
int is_started = 0;
float size_mul = 2.2;
int game_over = 0;
int victory = 0;
pos** board = 0;
size bsize;
Vector2 base_pos = {10., 50.};
Texture2D tiles_raw = LoadTexture("sprites/tiles.png");
Texture2D numbers = LoadTexture("sprites/numbers.png");
Texture2D faces = LoadTexture("sprites/faces.png");
Texture2D* tiles = get_tile_splices(&tiles_raw);
choose_board(&board, &bsize, &screen_height, &screen_width);
//print_board(board, &bsize);
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Lelle gjorde en minesweeper klon", 10, 10, 25, BLACK);
if (!game_over) {
Vector2 mouse_pos = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
game_over = dig(board, &bsize, 1, (int) (mouse_pos.x - base_pos.x) / 16./size_mul, (int) (mouse_pos.y - base_pos.y) / 16./size_mul);
}
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
game_over = dig(board, &bsize, 0, (int) (mouse_pos.x - base_pos.x) / 16./size_mul, (int) (mouse_pos.y - base_pos.y) / 16./size_mul);
}
victory = check_victory(board, &bsize);
if (victory) {
game_over = 1;
}
}
draw_board(board, &bsize, base_pos.x, base_pos.y, size_mul, tiles, game_over);
EndDrawing();
/*for (int i = 0; i < bsize.x * bsize.y; i++) {
UnloadTexture(clear[i]);
}*/
}
return 0;
}