-
Notifications
You must be signed in to change notification settings - Fork 0
/
healthBar.h
33 lines (30 loc) · 828 Bytes
/
healthBar.h
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
#include "SDL.h"
#include "gameData.h"
#include "clock.h"
#include "drawable.h"
#include "ioMod.h"
class HealthBar : public Drawable {
public:
HealthBar(const std::string&);
void draw() const;
void update(Uint32);
void reset() { currentLength = barRect.w; }
HealthBar(const HealthBar&) = delete;
HealthBar& operator=(const HealthBar&) = delete;
virtual int getScaledWidth() const { return barRect.w; }
virtual int getScaledHeight() const { return barRect.h; }
virtual const Image* getImage() const {
throw std::string("No image in HealthBar");
}
private:
SDL_Renderer* renderer;
SDL_Rect barRect;
Clock& clock;
int currentLength;
int increment;
float interval; // elapsed time for each decrement (1000ms=1sec)
int deltaTime;
SDL_Color barColor;
SDL_Color backColor;
IoMod& io;
};