-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPole.cpp
95 lines (79 loc) · 1.97 KB
/
Pole.cpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <SFML/Graphics/RectangleShape.hpp>
#include "Pole.h"
Pole::Pole(float _x, float _y, int _num,sf::String _otazka) {
x = _x - w/2;
y = _y;
num = _num;
otazka = _otazka;
}
Pole::Pole(float _x, float _y, int _num, sf::String _otazka, int _myRow, Placement _position) {
x = _x - w/2;
y = _y;
num = _num;
otazka = _otazka;
myRow = _myRow;
position = _position;
}
sf::RectangleShape Pole::show() {
sf::RectangleShape box(sf::Vector2f(w,h));
box.setPosition(x, y);
switch (owner){
case PLAYER1:
box.setFillColor(sf::Color::Red);
break;
case PLAYER2:
box.setFillColor(sf::Color::Blue);
break;
case WRONG:
box.setFillColor(sf::Color::Black);
break;
case NONE:
box.setFillColor(sf::Color::White);
break;
}
return box;
}
sf::CircleShape Pole::circleShow() {
sf::CircleShape Octagon(40, 8);
Octagon.setPosition(x, y);
switch (owner){
case PLAYER1:
Octagon.setFillColor(sf::Color::Red);
break;
case PLAYER2:
Octagon.setFillColor(sf::Color::Blue);
break;
case WRONG:
Octagon.setFillColor(sf::Color::Black);
break;
case NONE:
Octagon.setFillColor(sf::Color::White);
break;
}
return Octagon;
}
bool Pole::collision(sf::Vector2i mouseCoords) {
sf::IntRect colisionArea(static_cast<int>(x), static_cast<int>(y), w, h);
return colisionArea.contains(mouseCoords);
}
void Pole::setOwner(Owner newPlayer){
owner = newPlayer;
}
Owner Pole::getOwner() const {
return owner;
}
const sf::String &Pole::getOtazka() const {
return otazka;
}
int Pole::getNum() const{
return num;
}
sf::Vector2f Pole::getTextCoords() {
return {x + w * 1/2, y + (h * 1/3)};
}
Placement Pole::getPlacement() {
return position;
}
int Pole::getRow() {
return myRow;
}