-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCirclePointers.cpp
More file actions
58 lines (49 loc) · 1.62 KB
/
CirclePointers.cpp
File metadata and controls
58 lines (49 loc) · 1.62 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
#include "CirclePointers.h"
void CirclePointers::initVariables(unsigned short totalPlayers)
{
this->totalPlayers = totalPlayers;
this->red = sf::Color(250, 50, 50);
this->green = sf::Color(100, 250, 50);
}
void CirclePointers::initCirclePointers(unsigned short totalPlayers)
{
this->playerTurnPointers["PLAYER1"] = new sf::CircleShape(10);
this->playerTurnPointers["PLAYER2"] = new sf::CircleShape(10);
this->playerTurnPointers["PLAYER3"] = new sf::CircleShape(10);
this->playerTurnPointers["PLAYER4"] = new sf::CircleShape(10);
this->playerTurnPointers["PLAYER1"]->setFillColor(this->green);
this->playerTurnPointers["PLAYER2"]->setFillColor(this->red);
this->playerTurnPointers["PLAYER3"]->setFillColor(this->red);
this->playerTurnPointers["PLAYER4"]->setFillColor(this->red);
this->playerTurnPointers["PLAYER1"]->setPosition(1155, 216);
this->playerTurnPointers["PLAYER2"]->setPosition(1155, 256);
this->playerTurnPointers["PLAYER3"]->setPosition(1155, 296);
this->playerTurnPointers["PLAYER4"]->setPosition(1155, 336);
}
CirclePointers::CirclePointers(unsigned short totalPlayers)
{
this->initVariables(totalPlayers);
this->initCirclePointers(totalPlayers);
}
CirclePointers::~CirclePointers()
{
}
void CirclePointers::update(int player_turn)
{
int i = 0;
for (auto& it : this->playerTurnPointers)
{
if (i == player_turn)
it.second->setFillColor(this->green);
else
it.second->setFillColor(this->red);
i++;
}
}
void CirclePointers::render(sf::RenderTarget* target)
{
for (auto& it : this->playerTurnPointers)
{
target->draw(*it.second);
}
}