-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.hpp
More file actions
32 lines (26 loc) · 774 Bytes
/
button.hpp
File metadata and controls
32 lines (26 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "raylib.h"
class Button {
int x, y;
int height, width;
const char* text;
public:
Button(int x, int y, int height, const char* text) {
this->x = x;
this->y = y;
this->height = height;
this->text = text;
}
bool isPressed() {
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
if((GetMouseX() > x && GetMouseX() < x+MeasureText(text, height)) && (GetMouseY() > y && GetMouseY() < y+height))
return true;
}
return false;
}
void drawButton() {
if((GetMouseX() > x && GetMouseX() < x+MeasureText(text, height)) && (GetMouseY() > y && GetMouseY() < y+height))
DrawText(text, x, y, height, ORANGE);
else
DrawText(text, x, y, height, GRAY);
}
};