-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.hpp
49 lines (27 loc) · 1.13 KB
/
button.hpp
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
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
#include<string>
namespace Useful{
inline float pointDistance(sf::Vector2f p1, sf::Vector2f p2){
return(std::sqrt(std::pow(p1.x-p2.x,2)+std::pow(p1.y-p2.y,2)));
}
class Button{
sf::RectangleShape rect;
sf::Color color;
sf::Color changeColor;
std::string information;
void draw(sf::RenderWindow& win);
bool inside() ;
public:
Button();
Button(sf::Vector2f pos, sf::Vector2f size_, sf::Color color,sf::Color secondaryColor, std::string type);
void update(sf::RenderWindow& win);
bool checkMouse() ;
inline sf::Vector2f getSize(){return rect.getSize();};
inline void setSize(sf::Vector2f size_){ rect.setSize(size_); }
inline void setPosition(sf::Vector2f pos){rect.setPosition(pos);}
inline sf::Vector2f getPosition(){ return rect.getPosition();}
inline std::string getInformation(){return information; }
};
}