Working on a Pong clone. Having serious issues with trying to display the score on the screen. Alot of things I've found are using images but I just want to use text to display the score number. I'm trying to use the SDL TTF library to load a font and display it but it won't display correctly. I found this question How to blit Score on screen in SDL? and the reply said to use SDL_BlitSurface() which I tried and I just got a build error (assuming I was doing it correctly)
Here's the function I call for drawing the score:
void Pong::drawScore(){
leftScoreChar = leftScore;
rightScoreChar = rightScore;
SDL_Color text_color = {255, 255, 255};
score = TTF_RenderText_Solid(font,
&leftScoreChar,
text_color);
score2 = TTF_RenderText_Solid(font,
&rightScoreChar,
text_color);
leftScoreText = SDL_CreateTextureFromSurface(renderer, score);
rightScoreText = SDL_CreateTextureFromSurface(renderer, score2);
SDL_RenderCopy(renderer, leftScoreText, NULL, &scoreA);
SDL_RenderCopy(renderer, rightScoreText, NULL, &scoreB);
}
Which when run outputs this: https://goo.gl/dZxDEa
Aplogies, I would put an image in the post but apparently I can't.
And the score won't display unless the integer storing the score is made equal to 1 for some reason and displays zero. And the score is deffinatly increasing cause I have the game output the score to the console to make sure. So what am I doing wrong that's making my score display incorrectly and have some 00 thing?