Hide Player after dying

I’m working on a 2D Platformer game, but i couldn’t find out how to hide the player after dying, or any other enemy, any help, i tried SDL_DestroyTexture() function, but i doesn’t seem to work.

Usually you would have something like a flag in your player class/structure, which is always examined - if it’s, say true, then the player is displayed, otherwise it isn’t.

This flag would change if something dangerous was touched/ran into/time ran out etc etc

Usually you would have something like a flag in your player class/structure, which is always examined - if it’s, say true, then the player is displayed, otherwise it isn’t.

This flag would change if something dangerous was touched/ran into/time ran out etc etc
Thanks :smiley: , i didn’t think about it.

No problem!

i usually do like this:

for example: If (playerShow == true){
blit the player

               else
               don't blit

i usually do like this:

for example: If (playerShow == true){
blit the player

               else
               don't blit

You can replace “If (playerShow == true)” by “If (playerShow)” :slight_smile:

I can suggest you a sophisticated solution. Simply, use state machines. All my games are made with that and I don’t have any troubles like this. But, the problem is some code are “copy” of another code only chance one or two lines, nevertheless it’s very very good to make games where the main character have many abilities or powers.
See here one example of state machine in my game (it’s very larger):
http://sourceforge.net/p/dangeroustux/code/ci/master/tree/src/player.cpp