menu: mode

This commit is contained in:
_N3m0 2024-03-14 08:37:04 +01:00
parent c11a549778
commit 33c48e4538
3 changed files with 51 additions and 36 deletions

87
main.c
View File

@ -34,6 +34,8 @@ typedef enum GameType {
} GameType; } GameType;
GameType current_game_type = BEGINNER; GameType current_game_type = BEGINNER;
char *current_game_name = "beginner";
Color current_game_color = GREEN;
typedef struct Vec2i { typedef struct Vec2i {
int x; int x;
@ -53,7 +55,8 @@ int grid_len = 0;
Rectangle grid = {0}; Rectangle grid = {0};
const Color text_color = RED; const Color text_color = BLACK;
const Color hover_color = RED;
#define INIT_TEXTURE(img, tex) \ #define INIT_TEXTURE(img, tex) \
Image img = {0}; \ Image img = {0}; \
@ -266,6 +269,8 @@ int main(void)
win_texture = LoadTexture("ressources/win.png"); win_texture = LoadTexture("ressources/win.png");
playing_texture = LoadTexture("ressources/playing.png"); playing_texture = LoadTexture("ressources/playing.png");
fixed_tile_texture = LoadTexture("ressources/fixed_tile.png"); fixed_tile_texture = LoadTexture("ressources/fixed_tile.png");
double_tile_texture = LoadTexture("ressources/tile_2.png");
triple_tile_texture = LoadTexture("ressources/tile_3.png");
screen_resize_handle(); screen_resize_handle();
@ -300,14 +305,20 @@ int main(void)
int resize = 0; int resize = 0;
if (IsKeyPressed(KEY_I)) { if (IsKeyPressed(KEY_I)) {
current_game_type = INTERMEDIATE; current_game_type = INTERMEDIATE;
current_game_name = "intermediate";
current_game_color = ORANGE;
resize = 1; resize = 1;
} }
if (IsKeyPressed(KEY_B)) { if (IsKeyPressed(KEY_B)) {
current_game_type = BEGINNER; current_game_type = BEGINNER;
current_game_name = "beginner";
current_game_color = GREEN;
resize = 1; resize = 1;
} }
if (IsKeyPressed(KEY_E)) { if (IsKeyPressed(KEY_E)) {
current_game_type = EXPERT; current_game_type = EXPERT;
current_game_name = "expert";
current_game_color = RED;
resize = 1; resize = 1;
} }
if (resize || IsKeyPressed(KEY_R)) { if (resize || IsKeyPressed(KEY_R)) {
@ -357,23 +368,27 @@ int main(void)
13, 30, text_color 13, 30, text_color
); );
int diff_pad = 10; // int diff_pad = 10;
Vec2i diff_button[3] = {0}; // Vec2i diff_button[3] = {0};
char *diff_name[3] = {"BEGINNER", "INTERMEDIATE", "EXPERT"}; // char *diff_name[3] = {"BEGINNER", "INTERMEDIATE", "EXPERT"};
for (int i=0; i<3; i++) { // for (int i=0; i<3; i++) {
diff_button[i] = (Vec2i) { // diff_button[i] = (Vec2i) {
fixed_tile_texture.width*i + diff_pad*i, 0 // triple_tile_texture.width*i + diff_pad*i, 0
}; // };
DrawTexture( // DrawTexture(
fixed_tile_texture, // TODO: double_fixed_tile_texture // triple_tile_texture, // TODO: double_fixed_tile_texture
diff_button[i].x, diff_button[i].y, // diff_button[i].x, diff_button[i].y,
WHITE // WHITE
); // );
DrawText(diff_name[i], // DrawText(diff_name[i],
diff_button[i].x + 9, diff_button[i].y + 15, // diff_button[i].x + 9, diff_button[i].y + 15,
20, text_color // 20, text_color
); // );
} // }
DrawTexture(triple_tile_texture, 0, 0, WHITE);
DrawText("mode :", 13, 5, 20, text_color);
DrawText(current_game_name, 13, 25, 20.0f, current_game_color);
DrawRectangleRec(grid, (Color) { DrawRectangleRec(grid, (Color) {
.r = 0xC6, .g = 0xC6, .b = 0xC6, .a = 255 .r = 0xC6, .g = 0xC6, .b = 0xC6, .a = 255
@ -475,24 +490,24 @@ int main(void)
{ {
take_screenshot = 1; take_screenshot = 1;
} }
if (collision(diff_button[0], fixed_tile_texture, // if (collision(diff_button[0], triple_tile_texture,
mouse_x, mouse_y)) // mouse_x, mouse_y))
{ // {
current_game_type = BEGINNER; // current_game_type = BEGINNER;
reload_game(); // reload_game();
} // }
if (collision(diff_button[1], fixed_tile_texture, // if (collision(diff_button[1], triple_tile_texture,
mouse_x, mouse_y)) // mouse_x, mouse_y))
{ // {
current_game_type = INTERMEDIATE; // current_game_type = INTERMEDIATE;
reload_game(); // reload_game();
} // }
if (collision(diff_button[2], fixed_tile_texture, // if (collision(diff_button[2], triple_tile_texture,
mouse_x, mouse_y)) // mouse_x, mouse_y))
{ // {
current_game_type = EXPERT; // current_game_type = EXPERT;
reload_game(); // reload_game();
} // }
} }
} }
EndDrawing(); EndDrawing();

BIN
ressources/tile_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

BIN
ressources/tile_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B