Implement WalkLeft and WalkRight character states

This commit is contained in:
Chris Robinson 2013-01-19 16:19:47 -08:00
parent a7b07ee5cf
commit 68779375b2
3 changed files with 12 additions and 1 deletions

View file

@ -273,7 +273,14 @@ namespace MWMechanics
if(dir.length() >= 0.1f) if(dir.length() >= 0.1f)
{ {
if(dir.y < 0.0f) if(std::abs(dir.x/2.0f) > std::abs(dir.y))
{
if(dir.x > 0.0f)
newstate = CharState_WalkRight;
else if(dir.x < 0.0f)
newstate = CharState_WalkLeft;
}
else if(dir.y < 0.0f)
newstate = CharState_WalkBack; newstate = CharState_WalkBack;
else else
newstate = CharState_WalkForward; newstate = CharState_WalkForward;

View file

@ -41,6 +41,8 @@ static const struct {
{ CharState_WalkForward, "walkforward", Ogre::Vector3(0.0f, 1.0f, 0.0f) }, { CharState_WalkForward, "walkforward", Ogre::Vector3(0.0f, 1.0f, 0.0f) },
{ CharState_WalkBack, "walkback", Ogre::Vector3(0.0f, 1.0f, 0.0f) }, { CharState_WalkBack, "walkback", Ogre::Vector3(0.0f, 1.0f, 0.0f) },
{ CharState_WalkLeft, "walkleft", Ogre::Vector3(1.0f, 0.0f, 0.0f) },
{ CharState_WalkRight, "walkright", Ogre::Vector3(1.0f, 0.0f, 0.0f) },
{ CharState_Dead, "death1", Ogre::Vector3(1.0f, 1.0f, 0.0f) }, { CharState_Dead, "death1", Ogre::Vector3(1.0f, 1.0f, 0.0f) },
}; };

View file

@ -19,6 +19,8 @@ enum CharacterState {
CharState_WalkForward, CharState_WalkForward,
CharState_WalkBack, CharState_WalkBack,
CharState_WalkLeft,
CharState_WalkRight,
CharState_Dead CharState_Dead
}; };