The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Hide Player after dying
AbdelOuery


Joined: 28 Aug 2014
Posts: 4
Location: Morocco
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.
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
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
AbdelOuery


Joined: 28 Aug 2014
Posts: 4
Location: Morocco
MrTAToad wrote:
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 Very Happy , i didn't think about it.
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
No problem!
maosk21


Joined: 17 Jun 2014
Posts: 22
i usually do like this:

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


else
don't blit
Alex


Joined: 19 Sep 2014
Posts: 35
maosk21 wrote:
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)" Smile
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
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