-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCScreenText.cpp
61 lines (44 loc) · 1.14 KB
/
CScreenText.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
60
61
#include "CScreenText.h"
#include "CAppStateGame.h"
CScreenText CScreenText::ScreenTextControl;
CScreenText::CScreenText()
{
Surf_Text = NULL;
font = NULL;
textColor.r = 255;
textColor.g = 255;
textColor.b = 255;
}
bool CScreenText::OnLoad()
{
OnCleanup();
font = TTF_OpenFont( "FOO.ttf", 28 );
if(font == NULL)
{
return false;
}
}
const void CScreenText::OnLoop()
{
}
void CScreenText::OnRender(SDL_Surface* Surf_Display, int playerHealth, bool canAttack)
{
sprintf(health, "Health: %d", playerHealth);
Surf_Text = TTF_RenderText_Solid(font, health, textColor);
CSurface::OnDraw(Surf_Display, Surf_Text, 0, 0);
SDL_FreeSurface(Surf_Text);
Surf_Text = NULL;
// The following is to see test stuff on the screen.. for testing!
sprintf(testing, "Objects: %d", CEntity::EntityList.size());
Surf_Text = TTF_RenderText_Solid(font, testing, textColor);
CSurface::OnDraw(Surf_Display, Surf_Text, 0, 20);
SDL_FreeSurface(Surf_Text);
Surf_Text = NULL;
}
void CScreenText::OnCleanup()
{
SDL_FreeSurface(Surf_Text);
Surf_Text = NULL;
TTF_CloseFont(font);
font = NULL;
}