-
Notifications
You must be signed in to change notification settings - Fork 0
/
CharIndicatorContainer.cpp
59 lines (48 loc) · 1.34 KB
/
CharIndicatorContainer.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
#include "CharIndicatorContainer.h"
CharIndicatorContainer::CharIndicatorContainer(GameMaster* gameMaster, SDL_Renderer* renderer, SDL_Rect rect)
{
this->gameMaster = gameMaster;
this->location = rect;
// adding padding
this->location.x += 50;
this->location.w -= 50;
SDL_Rect indicatorLocation; // this might cause an issue as we keep giving the same object to each 'cator
for (int i = 1; i < gameMaster->GetNumberOfPlayers(); i++)
{
indicatorLocation = {
location.x + ((location.w/gameMaster->GetNumberOfPlayers())*i),
location.y + location.h/2,
150, 150
};
indicators.push_back(new CharIndicator(renderer, indicatorLocation));
indicators.back()->SetHandSize(gameMaster->GetPlayerHandSize(i));
}
}
void CharIndicatorContainer::UpdateCharIndicators(int character, int prevCharacter)
{
if (character != 0)
{
character--;
indicators[character]->SetTurn(true);
}
if (prevCharacter != 0)
{
prevCharacter--;
indicators[prevCharacter]->SetHandSize(gameMaster->GetPlayerHandSize(prevCharacter + 1));
indicators[prevCharacter]->SetTurn(false);
}
}
CharIndicatorContainer::~CharIndicatorContainer()
{
for (CharIndicator* indicator : indicators)
{
delete indicator;
}
}
void CharIndicatorContainer::RenderCall(SDL_Renderer* renderer)
{
for (CharIndicator* indicator : indicators)
{
indicator->RenderCall(renderer);
}
}