-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumBox.cpp
More file actions
36 lines (31 loc) · 777 Bytes
/
Copy pathnumBox.cpp
File metadata and controls
36 lines (31 loc) · 777 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 "numBox.h"
numBox::numBox(SDL_Renderer *num_renderer, const char* font, SDL_Color Color, int size, int num):
num(num), num_renderer(num_renderer)
{
for (int i = 0; i < 10; i += 1){
num_array.push_back(new textBox((IntToString(i).c_str()), font, Color, size, num_renderer));
}
}
numBox::~numBox()
{
while (!num_array.empty()){
delete num_array.back();
num_array.pop_back();
}
}
void numBox::num_render(int num,int pX,int pY){
std::vector<int> numm;
if (num == 0){
num_array[0]->render(pX, pY);
return;
}
while (num != 0){
numm.push_back(num % 10);
num /= 10;
}
int posX = pX;
for (int i = numm.size() - 1; i >= 0; i -= 1){
num_array[numm[i]]->render(posX, pY);
posX += num_array[numm[i]]->src.w;
}
}