This is probably really simple, so hopefully i can get some help.
I'm trying to add a score board to my pong clone. I have all the movement input and collision detection setup, but i can't get the score to act right. I put the draw score function which is
score = r_Score.GetScore();
//Generate the message surface
show_score = TTF_RenderText_Solid( font, score.c_str(), textColor );
apply_surface(500, 20, show_score, screen);
SDL_FreeSurface(show_score);
but when the screen updates it doesn't just keep updating the score at 500,20 it just repeats it along the X-axis.
Any help would be great. Thanks.
have you checked the content of the score variable you get with r_Score.GetScore() ?
if your rendered text "repeats" along the x axis its quite likely that you are appending a string rather than adding to a integer:
for example, string score1 = "3";
score1+"2" is not "5" , its "32";
Ofcourse i'm guessing a bit wildly here as i can't see the rest of your code. (The r_Score class is probably where the error is, or possibly in the apply_surface function, allthough i'm guessing thats taken from lazy foo so it should be good)
If my guess is correct you should store the score as an integer and use a stringstream object to convert it to a string when its time to render it.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!