-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLivesViewer.cpp
More file actions
44 lines (30 loc) · 983 Bytes
/
LivesViewer.cpp
File metadata and controls
44 lines (30 loc) · 983 Bytes
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
#include "LivesViewer.h"
#include "GameManager.h"
LivesViewer::LivesViewer() :
texture_(nullptr), clip_() {
}
LivesViewer::LivesViewer(Texture* texture, SDL_Rect clip) :
texture_(texture), clip_(clip) {
}
LivesViewer::~LivesViewer()
{
}
/*void LivesViewer::render(Container* c, Uint32 time) {
int l = static_cast<GameManager*>(c)->getLives();
string s = std::to_string(l);
Texture msg(c->getGame()->getRenderer(),
"Lives: " + s,
*(c->getGame()->getServiceLocator()->getFonts()->getFont(
Resources::ARIAL24)), { COLOR(0xff000000) });
//int h = msg.getHeight();
//int w = msg.getWidth();
msg.render(c->getGame()->getRenderer(),
c->getGame()->getWindowWidth() / 4 - msg.getWidth(), c->getGame()->getWindowHeight() - 600);
}*/
void LivesViewer::render(Container* c, Uint32 time) {
int hp = static_cast<GameManager*>(c)->getLives();
for (int i = 1; i < hp + 1; i++) {
SDL_Rect dest = RECT((i * 40), 10, 50, 50);
texture_->render(dest, &clip_);
}
}