-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.cpp
More file actions
67 lines (57 loc) · 1.12 KB
/
button.cpp
File metadata and controls
67 lines (57 loc) · 1.12 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "button.h"
button::button(void)
{
x = 0;
y = 0;
width = 256;
height = 256;
strcpy(signal, "");
mouse[0] = 1;
mouse[1] = 1;
pressed = false;
}
button::button(int _x, int _y, int _width, int _height)
{
x = _x;
y = _y;
width = _width;
height = _height;
strcpy(signal, "");
mouse[0] = 1;
mouse[1] = 1;
pressed = false;
}
button::~button(void)
{
}
sf::Sprite button::getSprite() {
sf::Sprite abc = sf::Sprite();
return abc;
}
void button::update(bool lClicked) {
pressed = false;
strcpy(signal, "");
if ( lClicked && isClicked( mouse ) ) {
pressed = true;
//printf("%i, %i\n", mouse[0], mouse[1]);
//strcpy(signal, "BUTTON PRESSED\n");
}
}
bool button::isClicked( int mouse[2] ) {
//Check to see if a button is clicked.
if (IS_BETWEEN(mouse[0], x, x+width ) && IS_BETWEEN(mouse[1], y, y+height)) {
return true;
} else return false;
}
bool button::operator<(const button& b) const {
if (y < b.y) {
return true;
}
return false;
}
bool button::operator>(const button& b) const {
if (y > b.y) {
return true;
}
return false;
}