diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-16 18:11:02 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-16 18:11:02 +0000 |
commit | 5d1e44f80cd2fc8ebfb56096d9b2e82dee3ce39f (patch) | |
tree | be9b1e327c1c4063f06d67d996d57b8fd0795f8b | |
parent | 2150113f50b5a51b74594310d12cca55b9886e14 (diff) | |
download | PenguinYippies-5d1e44f80cd2fc8ebfb56096d9b2e82dee3ce39f.tar.gz PenguinYippies-5d1e44f80cd2fc8ebfb56096d9b2e82dee3ce39f.tar.bz2 PenguinYippies-5d1e44f80cd2fc8ebfb56096d9b2e82dee3ce39f.zip |
Working on textured button
-rw-r--r-- | src/gameCommon.h | 1 | ||||
-rw-r--r-- | src/ui.c | 23 | ||||
-rw-r--r-- | src/ui.h | 25 |
3 files changed, 49 insertions, 0 deletions
diff --git a/src/gameCommon.h b/src/gameCommon.h index c46671c..ceca8b8 100644 --- a/src/gameCommon.h +++ b/src/gameCommon.h @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <string.h> #include <raylib.h> #include <raymath.h> diff --git a/src/ui.c b/src/ui.c new file mode 100644 index 0000000..b1c00ce --- /dev/null +++ b/src/ui.c @@ -0,0 +1,23 @@ +#include "ui.h" +#include "game.h" + +TexturedButton createTexturedButton(Texture* texture, Rectangle rect, const char* message, + Color backgroundColor, Color foregroundColor) +{ + TexturedButton button; + button.texture = texture; + button.rect = rect; + strncpy((char*)button.message, message, UI_BUTTON_NAME_MAX); + button.backgroundColor = backgroundColor; + button.foregroundColor = foregroundColor; + button.isPressed = false; + + return button; +} + +bool updateTexturedButton(TexturedButton* button) +{ + // Draw the button. + + return button->isPressed; +} diff --git a/src/ui.h b/src/ui.h new file mode 100644 index 0000000..717435b --- /dev/null +++ b/src/ui.h @@ -0,0 +1,25 @@ +#include "gameCommon.h" + +#define UI_BUTTON_NAME_MAX 50 + +#ifndef UI_H +#define UI_H + +typedef struct TexturedButton { + Texture* texture; // Can be in a animation or assets. + Rectangle rect; + + char message[UI_BUTTON_NAME_MAX]; + + Color backgroundColor; + Color foregroundColor; + + bool isPressed; +} TexturedButton; + +// Buttons don't need to be freed from memory. The button doesn't handle the texture memory. +TexturedButton createTexturedButton(Texture* texture, Rectangle rect, const char* message, + Color backgroundColor, Color foregroundColor); +bool updateTexturedButton(TexturedButton* button); + +#endif |