From 47f914f462c8deb712f0fcb1260e7634c89425f9 Mon Sep 17 00:00:00 2001 From: veradec Date: Sat, 24 Oct 2026 00:05:19 +0530 Subject: re-formatting main.h to helpers.h and a new headers for ante --- Makefile | 2 +- TODO.md | 4 +++- ante.h | 9 +++++++++ helpers.h | 31 +++++++++++++++++++++++++++++++ main.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++------------ main.h | 33 --------------------------------- 6 files changed, 95 insertions(+), 47 deletions(-) create mode 100644 ante.h create mode 100644 helpers.h delete mode 100644 main.h diff --git a/Makefile b/Makefile index 458e780..60b9de9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -main: main.c main.h +main: main.c helpers.h ante.h gcc main.c -lraylib -o output/main ./output/main diff --git a/TODO.md b/TODO.md index 18fb0b7..382b693 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,8 @@ [] Cmatrix for the Title Menu Background [] find a wood-click sfx for clicks - +[] make the binary texture for the music bars +[] Make the Menu Screen Work + [] Try Anchoring the insides of Each rectangle, to the rectangle. -- Done [X] hold FPS settings when vsync_check is true [X] Check the vsync_check value and then set the VSYNC_HINT to true diff --git a/ante.h b/ante.h new file mode 100644 index 0000000..02c48f0 --- /dev/null +++ b/ante.h @@ -0,0 +1,9 @@ +char *ante[12] = {"Bit", "Byte", "KiloByte", "MegaByte", + "GigaByte", "TeraByte", "PetaByte", "ExaByte", + "ZettaByte", "YottaByte", "RonnaBye", "QuettaByte"}; + +int ante_score[12] = { + 300, 600, 1200, 2400, + 3000, 3500, 4000, 5000, + 6000,7000,8000,9000}; + diff --git a/helpers.h b/helpers.h new file mode 100644 index 0000000..d6479f9 --- /dev/null +++ b/helpers.h @@ -0,0 +1,31 @@ +#include + +#define TEXT_FONT text_font + +#define WriteDrawText(text, posX, posY, fontSize, color) \ + DrawText(text, posX - (MeasureText(text, fontSize) / 2), posY, fontSize, \ + color); + +#define WriteDrawTextFont(font, text, posX, posY, fontSize, spacing, color) DrawTextEx(font, text, (Vector2){(posX - MeasureTextEx(font, text, fontSize, spacing).x/2), posY}, fontSize, spacing, color); + +#define WriteText(text, posX, posY, fontSize, color) DrawTextEx(TEXT_FONT, text, (Vector2){(posX - MeasureTextEx(TEXT_FONT, text, fontSize, 0).x/2), posY}, fontSize, 0, color); + +#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} + + +#define IsMouseInside(rec) CheckCollisionPointRec(mouse_position, rec) + +typedef enum ScreenType { + TitleScreen, SettingsScreen, GameStartScreen +} ScreenType; + +void MainMenu(); +void SettingsMenu(); +void LoadConfiguration(); +void WriteConfiguration(); +void SetVariables(char* line); + diff --git a/main.c b/main.c index 16e653d..b0511a5 100644 --- a/main.c +++ b/main.c @@ -1,12 +1,14 @@ #include #include -#include "main.h" #include #include #include #include -ScreenType screentype = MainScreen; +#include "helpers.h" +#include "ante.h" + +ScreenType screentype = GameStartScreen; int width = 1920; int height = 1080; int font_size = 12; @@ -32,23 +34,39 @@ int resolution_counter = 0; // Vsync bool vsync_check = false; +#define BTN_PADDING 25 void MainMenu() { WriteDrawTextFont(title_font, "Leetaro", width / 2, height / 5, font_size * 10, 0, BLACK); - /* DrawTextEx(font, text, position, fontSize, spacing, color); */ + // Play Button + - WriteText("Play", width / 2, height / 2, font_size * 5, BLACK); + Rectangle play_btn = MakeBtn(width/2, height/2, "Play", font_size *5, BTN_PADDING); - Rectangle rec = MakeBtn(width/2, height/2 + (height/10), "Settings", font_size * 5, 25); + if (IsMouseInside(play_btn)) { + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { + WriteText("Play", width / 2, height / 2, font_size * 5, RED); + screentype = GameStartScreen; + } else { + WriteText("Play", width/2, height/2, font_size*5.2, BLACK); + ClearBackground(RAYWHITE); + } + } else { + WriteText("Play", width / 2, height / 2, font_size * 5, BLACK); + } + + // Settings Button + Rectangle rec = MakeBtn(width/2, height/2 + (height/10), "Settings", font_size * 5, BTN_PADDING); if (IsMouseInside(rec)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { - WriteText( "Settings", width / 2, height / 2 + (height / 10), - (font_size * 5 + 3), RED); + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { + WriteText("Settings", width / 2, height / 2 + (height / 10), + (font_size * 5 + 3), RED); + screentype = SettingsScreen; } else { WriteText( "Settings", width / 2, height / 2 + (height / 10), - font_size * 5, BLACK); + font_size * 5.1, BLACK); ClearBackground(RAYWHITE); } } else { @@ -68,7 +86,7 @@ void MainMenu() { CloseWindow(); exit(0); } else { - WriteText("Exit", width / 2, height / 2 + (height / 5), font_size * 5, + WriteText("Exit", width / 2, height / 2 + (height / 5), font_size * 5.2, BLACK); } } else { @@ -268,7 +286,7 @@ void SettingsMenu() { if (IsMouseInside(back_rec)) { if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { WriteConfiguration(); - screentype = MainScreen; + screentype = TitleScreen; } } @@ -384,6 +402,24 @@ void WriteConfiguration() { printf("INFO: Wrote Configuration\n"); } +void GameStart() { + ClearBackground(RAYWHITE); + Rectangle left_rect = MakeRect(width / 2 - width / (3), height / 10, + width / 3.5, height - height / 5); + + Rectangle middle_rect = + MakeRect(width / 2, height / 10, width / 3.5, + height - height / 5); + + Rectangle right_rect = + MakeRect(width / 2 + width / (3), height / 10, width / 3.5, + height - height / 5); + + DrawRectangleRec(left_rect, BLACK); + DrawRectangleRec(middle_rect, BLACK); + DrawRectangleRec(right_rect, BLACK); +} + int main() { LoadConfiguration(); @@ -400,13 +436,16 @@ int main() { BeginDrawing(); ClearBackground(RAYWHITE); switch (screentype) { - case MainScreen: + case TitleScreen: MainMenu(); break; case SettingsScreen: ClearBackground(RAYWHITE); SettingsMenu(); break; + case GameStartScreen: + ClearBackground(BLACK); + GameStart(); } EndDrawing(); } diff --git a/main.h b/main.h deleted file mode 100644 index 9bfdc91..0000000 --- a/main.h +++ /dev/null @@ -1,33 +0,0 @@ -#include - -#define TEXT_FONT text_font - -#define WriteDrawText(text, posX, posY, fontSize, color) \ - DrawText(text, posX - (MeasureText(text, fontSize) / 2), posY, fontSize, \ - color); - -#define WriteDrawTextFont(font, text, posX, posY, fontSize, spacing, color) DrawTextEx(font, text, (Vector2){(posX - MeasureTextEx(font, text, fontSize, spacing).x/2), posY}, fontSize, spacing, color); - -#define WriteText(text, posX, posY, fontSize, color) DrawTextEx(TEXT_FONT, text, (Vector2){(posX - MeasureTextEx(TEXT_FONT, text, fontSize, 0).x/2), posY}, fontSize, 0, color); - -#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} - - -#define IsMouseInside(rec) CheckCollisionPointRec(mouse_position, rec) -/* #define HIGHLIGHT_COLOR */ -/* #define CLICK_COLOR */ - -typedef enum ScreenType { - MainScreen, SettingsScreen -} ScreenType; - -void MainMenu(); -void SettingsMenu(); -void LoadConfiguration(); -void WriteConfiguration(); -void SetVariables(char* line); - -- cgit v1.2.3