You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.6 KiB
36 lines
1.6 KiB
#ifndef BUTTONS_H_
|
|
#define BUTTONS_H_
|
|
|
|
#include "raylib.h"
|
|
#include "../game.h"
|
|
|
|
#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
|
|
Vector2 position; // Linke obere Ecke des Buttons
|
|
Vector2 centerPosition; // Die Mitte des Buttons
|
|
char text[20]; // Text, den der Button zentriert anzeigt, aktuell max. 19 Zeichen
|
|
int state; // 0: default 1: hovered 2: pressed 3: released
|
|
int id; // Durch die ID wird dem Button eine Funktion zugeordnet
|
|
int fontSize; // FontSize kann für jeden Button individuell festgelegt werden
|
|
} Button;
|
|
|
|
// Textures: [0]: Normal [1]: Hovered [2]: Pressed [3]: Released
|
|
Button * ButtonInitButton(Texture2D textures[4], Vector2 *position, char *text, int textLEN, int fontSize, int id);
|
|
|
|
// executes the logic of one button of certain id - huge switch?
|
|
void ButtonExecuteButton(Button *button, Game * game);
|
|
|
|
int ButtonUpdateButtonState(Button * button);
|
|
|
|
void ButtonDrawButton(Button * button);
|
|
|
|
#endif |