-
Notifications
You must be signed in to change notification settings - Fork 0
/
rectangle.h
78 lines (60 loc) · 1.46 KB
/
rectangle.h
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
68
69
70
71
72
73
74
75
76
77
78
#ifndef rec
#define rec
#include<SFML/Graphics.hpp>
#include<SFML/Window.hpp>
#include<SFML/Audio.hpp>
#include<list>
#include<unistd.h> // for usleep(miliseconds);
#include<time.h>
#include<random>
#include "constants.h"
using namespace sf;
class Rectangle: public Drawable{
public:
RectangleShape rect;
Rectangle(Color col, float posx, float posy){
rect.setFillColor(col);
rect.setPosition(posx,posy);
Vector2f vector;
vector.x = windowWidth / numBars;
vector.y = (float)(rand() % windowHeight);
rect.setSize(vector);
rect.setRotation(180);
}
~Rectangle(){
}
inline bool operator>(Rectangle other){
return rect.getSize().y > other.getSize().y;
}
inline bool operator>=(Rectangle other){
return rect.getSize().y >= other.getSize().y;
}
inline bool operator<(Rectangle other){
return rect.getSize().y < other.getSize().y;
}
inline bool operator<=(Rectangle other){
return rect.getSize().y <= other.getSize().y;
}
// Getters
inline Color getFillColor(){
return rect.getFillColor();
}
inline Vector2f getSize(){
return rect.getSize();
}
inline float getPos(){
return rect.getPosition().x;
}
// Setters
inline void setPos(float posx){
rect.setPosition(posx, rect.getPosition().y);
}
inline void setScale(float factorX, float factorY){
rect.setScale(factorX,factorY);
}
private:
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const{
target.draw(rect,states);
}
};
#endif