From 33c48e4538e188c0e6574d6f2a34a3a07e86949f Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Thu, 14 Mar 2024 08:37:04 +0100 Subject: [PATCH] menu: mode --- main.c | 87 +++++++++++++++++++++++++----------------- ressources/tile_2.png | Bin 0 -> 506 bytes ressources/tile_3.png | Bin 0 -> 593 bytes 3 files changed, 51 insertions(+), 36 deletions(-) create mode 100644 ressources/tile_2.png create mode 100644 ressources/tile_3.png diff --git a/main.c b/main.c index 6600fc5..0cad1f9 100644 --- a/main.c +++ b/main.c @@ -34,6 +34,8 @@ typedef enum GameType { } GameType; GameType current_game_type = BEGINNER; +char *current_game_name = "beginner"; +Color current_game_color = GREEN; typedef struct Vec2i { int x; @@ -53,7 +55,8 @@ int grid_len = 0; Rectangle grid = {0}; -const Color text_color = RED; +const Color text_color = BLACK; +const Color hover_color = RED; #define INIT_TEXTURE(img, tex) \ Image img = {0}; \ @@ -266,6 +269,8 @@ int main(void) win_texture = LoadTexture("ressources/win.png"); playing_texture = LoadTexture("ressources/playing.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(); @@ -300,14 +305,20 @@ int main(void) int resize = 0; if (IsKeyPressed(KEY_I)) { current_game_type = INTERMEDIATE; + current_game_name = "intermediate"; + current_game_color = ORANGE; resize = 1; } if (IsKeyPressed(KEY_B)) { current_game_type = BEGINNER; + current_game_name = "beginner"; + current_game_color = GREEN; resize = 1; } if (IsKeyPressed(KEY_E)) { current_game_type = EXPERT; + current_game_name = "expert"; + current_game_color = RED; resize = 1; } if (resize || IsKeyPressed(KEY_R)) { @@ -357,23 +368,27 @@ int main(void) 13, 30, text_color ); - int diff_pad = 10; - Vec2i diff_button[3] = {0}; - char *diff_name[3] = {"BEGINNER", "INTERMEDIATE", "EXPERT"}; - for (int i=0; i<3; i++) { - diff_button[i] = (Vec2i) { - fixed_tile_texture.width*i + diff_pad*i, 0 - }; - DrawTexture( - fixed_tile_texture, // TODO: double_fixed_tile_texture - diff_button[i].x, diff_button[i].y, - WHITE - ); - DrawText(diff_name[i], - diff_button[i].x + 9, diff_button[i].y + 15, - 20, text_color - ); - } + // int diff_pad = 10; + // Vec2i diff_button[3] = {0}; + // char *diff_name[3] = {"BEGINNER", "INTERMEDIATE", "EXPERT"}; + // for (int i=0; i<3; i++) { + // diff_button[i] = (Vec2i) { + // triple_tile_texture.width*i + diff_pad*i, 0 + // }; + // DrawTexture( + // triple_tile_texture, // TODO: double_fixed_tile_texture + // diff_button[i].x, diff_button[i].y, + // WHITE + // ); + // DrawText(diff_name[i], + // diff_button[i].x + 9, diff_button[i].y + 15, + // 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) { .r = 0xC6, .g = 0xC6, .b = 0xC6, .a = 255 @@ -475,24 +490,24 @@ int main(void) { take_screenshot = 1; } - if (collision(diff_button[0], fixed_tile_texture, - mouse_x, mouse_y)) - { - current_game_type = BEGINNER; - reload_game(); - } - if (collision(diff_button[1], fixed_tile_texture, - mouse_x, mouse_y)) - { - current_game_type = INTERMEDIATE; - reload_game(); - } - if (collision(diff_button[2], fixed_tile_texture, - mouse_x, mouse_y)) - { - current_game_type = EXPERT; - reload_game(); - } + // if (collision(diff_button[0], triple_tile_texture, + // mouse_x, mouse_y)) + // { + // current_game_type = BEGINNER; + // reload_game(); + // } + // if (collision(diff_button[1], triple_tile_texture, + // mouse_x, mouse_y)) + // { + // current_game_type = INTERMEDIATE; + // reload_game(); + // } + // if (collision(diff_button[2], triple_tile_texture, + // mouse_x, mouse_y)) + // { + // current_game_type = EXPERT; + // reload_game(); + // } } } EndDrawing(); diff --git a/ressources/tile_2.png b/ressources/tile_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a4f0dc49c3c02ee48ba4cae5f4cbd472a87b65ed GIT binary patch literal 506 zcmeAS@N?(olHy`uVBq!ia0vp^DL`z*!3-qlzV7P*QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`rv>k(2^Z);!zkmPk+qdukzrWwU zefjd`D-itn@#E*upPM#q>g((K@Zm#kZLP1bZ(u+`U|>K{ppUDo%fW*OJv=;|ot>SW zoE#mUTwRlBSAaZt+0(@_B*Oje`IACT20RT96BOV5 z?s~+saS25Z1IosAa0c8kR&= z4sFK>&O=@hp{xHVeq3T9xcB9noX@TP{ei6;V=i_|tnuD{^W6)>Qv$!4Wv_89?%$vB zxMI=Wq{2y;(wHpbzi>1?+A_VK_wOI;nQnRIN4Az85^?WW`TB9@L+%CQd>>}S$Cv@V h$Cn!6nda-upao=e05J$$3Z4w2JYD@<);T3K0RRbC-`4;D literal 0 HcmV?d00001 diff --git a/ressources/tile_3.png b/ressources/tile_3.png new file mode 100644 index 0000000000000000000000000000000000000000..577cee03603ba85c7e9a839bb09dc6f1216098f4 GIT binary patch literal 593 zcmeAS@N?(olHy`uVBq!ia0vp^(}38BgBeJ623^tsQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`*9G{5xc&!%e}De}`}zOhZy@Xc|G%eBoqG1{S#52ti;K(ue}BJy`!;v( zTz7Z(fB*jN-@iXNIQZ_}yLowe|Nj2^_4CKCU%!6;{{8pw-#>r;eERfh^5n^`uC9H3 zeK&93Y;SM(@bGYRb@lLY_xASk_VV)g^YZj?b#`_+eE4u-VWG3Lvy+pPm#3?{yNk1n z%a<=-)~;O}6BFa%?&{{|GHu#4e}8{hR~L6T7dJOIJ3Bjfch{>yf9ilP=PdAuEM{Qf zI|9OtQ?>b|fnF8zba4!caDRI)I{1)*M9aekjyzE;HVx^Hj;m$1L{0hs|F}=W(M6BX z+)Jq1_}-`e?~aqnJu7o^Z)cr|dVSt#OY?nKvlm_ttKV9!37r?VKIwR7zJ1~T2*v15 z_G}rGx%}7r7wwFC+wiM9m9M|=|I*2AhI8{OHa^~edGqI`s}AhaaCGQ&Wt|ccLJ4)n z{Pm|-QvY>!zx+CB$^MUd@7bL9?6`L5%HH||JHvkM_<3phMCr$So#aes+CA>LbXwuC zR!Y|T{23chr7zYw{_oVDhNB{r; literal 0 HcmV?d00001