From de0dacd8147b9e7d56cb18ae12709b7e4041ec1a Mon Sep 17 00:00:00 2001 From: JanEhehalt Date: Fri, 6 Jan 2023 15:12:21 +0100 Subject: [PATCH] minor tweaks --- Ui/button.h | 16 ++++++++-------- Ui/debug.c | 7 ++++--- Ui/debug.h | 2 +- Ui/screenIDs.h | 2 +- main.c | 6 +++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Ui/button.h b/Ui/button.h index f8aa218..23fb19c 100644 --- a/Ui/button.h +++ b/Ui/button.h @@ -4,14 +4,14 @@ #include "raylib.h" #include "../game.h" -#define BUTTON_STATE_DEFAULT 0 -#define BUTTON_STATE_HOVERED 1 -#define BUTTON_STATE_PRESSED 2 -#define BUTTON_STATE_RELEASED 3 - -#define BUTTON_ID_CONTINUE 0 -#define BUTTON_ID_EXIT 1 -#define BUTTON_ID_START_GAME 2 +#define BUTTON_STATE_DEFAULT 0 // button is just there +#define BUTTON_STATE_HOVERED 1 // mouse is being hovered over the button +#define BUTTON_STATE_PRESSED 2 // left mouse button is down while hovering the button +#define BUTTON_STATE_RELEASED 3 // left mouse button is released while hovering the button, button code will be executed + +#define BUTTON_ID_CONTINUE 0 // going to game screen, supposed to be used from pause screen +#define BUTTON_ID_EXIT 1 // closing the game using exit code 0 +#define BUTTON_ID_START_GAME 2 // going to game screen, supposed to be used from mainmenu screen typedef struct Button{ Texture2D textures[4]; // [0]: Normal [1]: Hovered [2]: Pressed [3]: Released diff --git a/Ui/debug.c b/Ui/debug.c index 8bead17..af96d7c 100644 --- a/Ui/debug.c +++ b/Ui/debug.c @@ -9,6 +9,7 @@ void DebugDraw(Game *game, UiContainer *uiContainer){ char strings[10][41]; // Platz für bis zu 10 Strings der Länge 40 int lineamount = 0; // sollte aktuell gehalten werden, wie viele Lines sind aktuell im Strings Array + int neededWidth = MeasureText("1234567890123456789012345", DEBUG_FONT_SIZE); // sollte an den längsten debug String angepasst werden, damit dieser noch reinpasst // Hier die Debug Information in den Strings Array einfügen // im Endeffekt einfach im Array an der Stelle lineamount++ die Elemente einfügen @@ -21,13 +22,13 @@ void DebugDraw(Game *game, UiContainer *uiContainer){ sprintf(strings[lineamount++], "DEPTH: %d", (int)(game->inputHandler->cursorWorldPos.x + game->inputHandler->cursorWorldPos.y + game->inputHandler->selectedLayer)); // Drawed eine Box für die Debug Info - DrawRectangleLines(0, 0, 250, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 255}); - DrawRectangle(0, 0, 250, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 150}); + DrawRectangleLines(0, 0, neededWidth, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 255}); + DrawRectangle(0, 0, neededWidth, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 150}); // Drawed den Inhalt des "strings" Arrays int counter = 0; while(counter < lineamount){ - DrawText(strings[counter], 2, counter * DEBUG_FONT_SIZE + 2, DEBUG_FONT_SIZE, RED); + DrawText(strings[counter], 2, counter * DEBUG_FONT_SIZE + 2, DEBUG_FONT_SIZE, (Color){220, 25, 25, 255}); counter++; } } \ No newline at end of file diff --git a/Ui/debug.h b/Ui/debug.h index cc1b90b..6524983 100644 --- a/Ui/debug.h +++ b/Ui/debug.h @@ -4,7 +4,7 @@ #include "../game.h" #include "uiContainer.h" -#define DEBUG_FONT_SIZE 20 +#define DEBUG_FONT_SIZE 20 // Font size of the Debug window // Drawed das Debug Fenster in die obere Linke Ecke void DebugDraw(Game *game, UiContainer *uiContainer); diff --git a/Ui/screenIDs.h b/Ui/screenIDs.h index e55f992..4108644 100644 --- a/Ui/screenIDs.h +++ b/Ui/screenIDs.h @@ -1,7 +1,7 @@ #ifndef SCREENIDS_H_ #define SCREENIDS_H_ -#define SCREEN_EXIT 0 +#define SCREEN_EXIT 0 // Will exit the game using code 0 #define SCREEN_MAINMENU 1 #define SCREEN_OPTIONS 2 #define SCREEN_GAME 3 diff --git a/main.c b/main.c index ac85d42..946355c 100644 --- a/main.c +++ b/main.c @@ -38,9 +38,9 @@ int main(){ game->cursorSprite->x = GetMousePosition().x; game->cursorSprite->y = GetMousePosition().y; - BeginDrawing(); - ClearBackground(RAYWHITE); - switch(game->screen){ + BeginDrawing(); // Drawing ist grundsätzlich immer aktiviert + ClearBackground(RAYWHITE); // Screen wird in jedem Frame gecleared + switch(game->screen){ // Screenspecific Code case SCREEN_EXIT: printf("EXIT \n"); return 0;