-
Notifications
You must be signed in to change notification settings - Fork 0
/
health_widget.cpp
29 lines (26 loc) · 974 Bytes
/
health_widget.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
#include "health_widget.hpp"
#include "managers/kernel.hpp"
#include "a10_game.hpp"
//------------------------------------------------------------------------------
HealthWidget::HealthWidget(A10_Game* _game, string name, Kernel* k)
: Widget(name,k), game(_game), heart_img(k->graphicsMgr->loadImage("gfx/heart.png"))
{
assert(game);
this->setSize(Vect(heart_img.getSize().x * MAX_LIVES,
heart_img.getSize().y));
};
//------------------------------------------------------------------------------
void
HealthWidget::_draw()
{
Vect pos = this->getAbsPos();
pos.x += this->width;
for(int i=0; i<this->game->getPlayerLives(); ++i)
{
pos.x -= this->heart_img.getSize().x;
this->heart_img.draw(pos);
}
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------