Question

I have a

timer = TTF_RenderText_Solid( tfont, timeStr.str().c_str(), txtColor ); 
applySurface(500, 30, timer, screen);

and on the 'screen' surface I have also applied my character, and my wall. But for some reason I can't seem to see the timer unless I have already NULL the 'floorsurface' and the 'charsurface'. Am I doing something wrong?

Was it helpful?

Solution

Try putting timerUpdate() before SDL_Flip(screen). You are calling SDL_Flip, then you call timerUpdate(). So you think, OK, that's fine, next time the screen is flipped, I'll see the text. But what is happening is that you are blitting more surfaces on top before the screen is flipped again, and then you can't see the text because you blitted surfaces on top of it. All you need to do is change the order, so

timerUpdate();
if (SDL_Flip(screen) == -1) return 1; //Instead of the other way round

should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top