From 3dadad50c681b7a6481b5ae2ce0763d66d3257ea Mon Sep 17 00:00:00 2001 From: veradec Date: Wed, 21 Oct 2026 12:20:54 +0530 Subject: the music_level bar works --- main.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ main.h | 11 +++-------- 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 9267ef2..cb382c8 100644 --- a/main.c +++ b/main.c @@ -172,24 +172,83 @@ void SettingsMenu() { WriteDrawText("Master Level", width / 2 - (width / 6), height / 2 + (height / 10), (font_size * 2), BLACK); - - /* DrawRectangle(width/2 + (width/5) - font_size*2, height/2+(height/10), MeasureText("[]", font_size*2)*master_level, font_size*2, BLACK); */ - x + /* Rectangle master_rec = {width / 2 + (width / 5), height / 2 + (height / 10), */ + /* MeasureText("[]", font_size * 3) * master_level, */ + /* font_size * 2, BLACK}; */ + + Rectangle master_rec = MakeRect(width/2+(width/5), height/2 + (height/10), MeasureText("[]", font_size * 3) * master_level, font_size*2); + Rectangle master_bg = MakeRect(width/2+(width/5), height/2 + (height/10), MeasureText("[]", font_size * 3) * 9, font_size*2); + DrawRectangleRec(master_bg, WHITE); + DrawRectangleRec(master_rec, BLACK); + + if (IsMouseInside(master_bg)) { + float delta_mouse_scroll = GetMouseWheelMove(); + if (delta_mouse_scroll < 0) { + if (master_level > 0) { + master_level--; + } + } + if (delta_mouse_scroll > 0) { + if (master_level < 9) { + master_level++; + } + } + } + ////////////// // Music Level WriteDrawText("Music Level", width / 2 - (width / 6), height / 2 + (height / 10) * 2, (font_size * 2), BLACK); - WriteDrawText(sound_level[music_level], width/2+(width/5), height/2+(height/10)*2, (font_size*2), BLACK); - ////////////// + Rectangle music_rec = MakeRect(width/2+(width/5), height/2 + (height/10)*2, MeasureText("[]", font_size * 3) * music_level, font_size*2); + Rectangle music_bg = MakeRect(width/2+(width/5), height/2 + (height/10)*2, MeasureText("[]", font_size * 3) * 9, font_size*2); + + DrawRectangleRec(music_bg, WHITE); + DrawRectangleRec(music_rec, BLACK); + + + if (IsMouseInside(music_bg)) { + float delta_mouse_scroll = GetMouseWheelMove(); + if (delta_mouse_scroll < 0) { + if (music_level > 0) { + music_level--; + } + } + if (delta_mouse_scroll > 0) { + if (music_level < 9) { + music_level++; + } + } + } + + ////////////// // SFX Level WriteDrawText("SFX Level", width / 2 - (width / 6), height / 2 + (height / 10) * 3, (font_size * 2), BLACK); - WriteDrawText(sound_level[sfx_level], width/2+(width/5), height/2+(height/10)*3, (font_size*2), BLACK); + Rectangle sfx_rec = MakeRect(width/2+(width/5), height/2 + (height/10)*3, MeasureText("[]", font_size * 3) * sfx_level, font_size*2); + Rectangle sfx_bg = MakeRect(width/2+(width/5), height/2 + (height/10)*3, MeasureText("[]", font_size * 3) * 9, font_size*2); + + DrawRectangleRec(sfx_bg, WHITE); + DrawRectangleRec(sfx_rec, BLACK); + + if (IsMouseInside(sfx_bg)) { + float delta_mouse_scroll = GetMouseWheelMove(); + if (delta_mouse_scroll < 0) { + if (sfx_level > 0) { + sfx_level--; + } + } + if (delta_mouse_scroll > 0) { + if (sfx_level < 9) { + sfx_level++; + } + } + } + ////////////// } diff --git a/main.h b/main.h index 91e636f..7813dfd 100644 --- a/main.h +++ b/main.h @@ -2,7 +2,9 @@ #define WriteDrawText(text, posX, posY, fontSize, color) DrawText(text, posX - (MeasureText(text, fontSize)/2), posY, fontSize, color); -/* #define DrawRect(posX,posY,) */ +#define DrawRect(posX,posY,width,height,color) DrawRectangle(posX - width/2, posY, width, height, color); + +#define MakeRect(posX, posY, width, height) {posX - width/2, posY, width, height}; #define MakeBtn(posX, posY, txt, fontSize, padding) {posX - MeasureText(txt, fontSize) / 2 - padding, posY - padding, MeasureText(txt, fontSize) + padding * 2, fontSize + padding * 2} @@ -18,10 +20,3 @@ typedef enum ScreenType { void MainMenu(); void SettingsMenu(); void LoadConfiguration(); - -char sound_level[10][21] = { - "[] ", "[][] ", "[][][] ", - "[][][][] ", "[][][][][] ", "[][][][][][] ", - "[][][][][][][] ", "[][][][][][][][] ", "[][][][][][][][][] ", - "[][][][][][][][][][]"}; - -- cgit v1.2.3