-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.cpp
More file actions
36 lines (29 loc) · 721 Bytes
/
Clock.cpp
File metadata and controls
36 lines (29 loc) · 721 Bytes
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
#include "Clock.h"
pClock::pClock()
{
font = TTF_OpenFont("content/GameOver/Pixeled.ttf", 100);
Color = { 0,0,255,255 };
surfaceText = TTF_RenderText_Solid(font, cArray, Color);
text = SDL_CreateTextureFromSurface(r, surfaceText);
messageRect = { 100,0,50,75 };
SDL_FreeSurface(surfaceText);
}
void pClock::tick()
{
if(iter == 100)
{
seconds++;
message = std::to_string(seconds);
int n = message.length();
strcpy_s(cArray, message.c_str());
iter = 0;
}
iter++;
}
void pClock::Render(SDL_Renderer* r)
{
surfaceText = TTF_RenderText_Solid(font, cArray, Color);
text = SDL_CreateTextureFromSurface(r, surfaceText);
SDL_FreeSurface(surfaceText);
SDL_RenderCopy(r, text, NULL, &messageRect);
}