-
Notifications
You must be signed in to change notification settings - Fork 1
/
StatusText.cpp
53 lines (46 loc) · 949 Bytes
/
StatusText.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
#include "common\Vector.h"
#include "common\Graphics.h"
#include "StatusText.h"
//! Constructor.
StatusText::StatusText()
{
setText("nothing", RED, 0);
mPos = Vector(0, 0);
mColor = RED;
}
//! Constructor.
/**
@param text The text to draw.
@param time How long to draw the text (seconds).
*/
StatusText::StatusText(string text, float x, float y, float time)
{
setText(text, RED, time);
mPos = Vector(x, y);
}
//! Destructor.
StatusText::~StatusText()
{
}
//! Draws the status text.
void StatusText::draw()
{
if(mTime > 0) {
if(mColor == RED)
gGraphics->drawBigDxFont(mText, mPos.x, mPos.y, 0xffff0000);
else if(mColor == GREEN)
gGraphics->drawBigDxFont(mText, mPos.x, mPos.y, 0xff00ff00);
}
}
//! Updates the timer.
void StatusText::update(float dt)
{
mTime -= dt;
}
//! Set the text and how long to draw it.
void StatusText::setText(string text, Color color, float time)
{
mText = text;
mTime = time;
mColor = color;
}