-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.cpp
59 lines (52 loc) · 1.34 KB
/
text.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
#include "text.h"
text::text()
{
verified = false;
inputText.str( "" );
noRobo.str("");
}
text::~text()
{
}
bool text::verifyNoRobo()
{
if (inputText.str() == noRobo.str())
{
verified = true;
}
return verified;
}
void text::loadText(TTF_Font* font,SDL_Renderer* renderer)
{
//verification background at beginning of chapter 3
verify.loadFromFile("images/verify.png",renderer);
//Set text color as black
SDL_Color textColor = { 255, 255, 255, 0xFF };
//the text to be verified
noRobo.str("fuck capitalism");
noRoboTextTexture.loadFromRenderedText( noRobo.str().c_str(),textColor,font,renderer );
//Enable text input
SDL_StartTextInput();
}
void text::renderVerification(TTF_Font* font,SDL_Renderer* renderer)
{
verify.render(0,0,NULL,0.0,NULL,SDL_FLIP_NONE,renderer);
SDL_Color textColor = { 255, 255, 255 };
if(inputText.str()!="")
{
inputTextTexture.loadFromRenderedText( inputText.str().c_str(), textColor,font,renderer );
}
noRoboTextTexture.render(150,350,NULL,0.0,NULL,SDL_FLIP_NONE,renderer);
if(inputText.str() != "")
{
inputTextTexture.render(150,370,NULL,0.0,NULL,SDL_FLIP_NONE,renderer);
}
}
void text::free()
{
//free text background
verify.free();
//Free Text images
noRoboTextTexture.free();
inputTextTexture.free();
}