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
|
class text {
public:
int xpos, ypos;
SDL_Surface * drawn;
void init(string, TTF_Font *, SDL_Color, int, int);
bool active;
};
text * textlist;
void text::init(string text, TTF_Font * font, SDL_Color c, int x, int y) {
xpos = x;
ypos = y;
drawn = TTF_RenderText_Solid(font, text.c_str(), c);
active = false;
}
int new_text(string text, TTF_Font * font, SDL_Color c, int x, int y) {
text * temp = new text[texts + 1];
if(texts != 0) {
for(int i = 0; i < texts; i++) {
temp[i] = textlist[i];
}
temp[texts].init(string text, TTF_Font * font, SDL_Color c, int x, int y);
delete [] textlist;
}
else {
temp[0].init(string text, TTF_Font * font, SDL_Color c, int x, int y);
delete textlist;
}
textlist = temp;
temp = NULL;
texts++;
return texts - 1;
}
| |