by Lokaar » Thu Jun 06, 2013 12:38 am
you could try making player states like
int playerState=0
if(playerState==0)
{
idle state in here
put switches and cases for each button that has function while the player is in the idle state, same for each other player state
example, pushing a button while idle would begin switching over to walking state, play the roll-up anim, some slight movement, then:
playerState=1; //this would switch to the walking state from within the idle state, which means the next state would take over handling
}
if(playerState==1)
{
walking state in here
movement when pushing a button
}
if(playerState==2)
{
jumping state in here
}
if(playerState==3)
{
dead state in here
no movement defined
}
etc
also allows you to have things happen before switching to another state and when entering another state (such as animations to go from idle to walking before switching to walking state, and from walking to idle when switching back to idle state)
then, all you have to do is playerState=3; to make them die
this doesn't only have to be used for the player