Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - herooftime24

Pages: [1]
1
Graphics / Animation Stops When 2 Keys Pressed
« on: July 03, 2011, 03:01:03 pm »
Here is my delimma I have a player object that animates fine when only one the movement keys is pressed (I use Left, Up, Right, Down) but when 2 of them are pressed together the player moves but stops animating
this is the code

Code: [Select]

#define keyLeft sf::Key::Left
#define keyRight sf::Key::Right
#define keyUp sf::Key::Up
#define keyDown sf::Key::Down

enum direction {Left, Up, Right, Down};

noMovement = true; //bool

float ElapsedTime = App.GetFrameTime();

if (App.GetInput().IsKeyDown(keyLeft))
{
if (Player.getDirection() != Left)
{
Player.getSprite().Play(6,9);
Player.setDirection(Left);
}
Player.Move(-100*ElapsedTime,0);
noMovement = false;
}

if (App.GetInput().IsKeyDown(keyUp))
{
if (Player.getDirection() != Up)
{
Player.getSprite().Play(3,6);
Player.setDirection(Up);
}
Player.Move(0,-100*ElapsedTime);
noMovement = false;
}

if (App.GetInput().IsKeyDown(keyRight))
{
if (Player.getDirection() != Right)
{
Player.getSprite().Play(9,12);
Player.setDirection(Right);
}
Player.Move(100*ElapsedTime,0);
noMovement = false;
}

if (App.GetInput().IsKeyDown(keyDown))
{
if (Player.getDirection() != Down)
{
Player.getSprite().Play(0,3);
Player.setDirection(Down);
}
Player.Move(0,100*ElapsedTime);
noMovement = false;
}

if(noMovement)
{
Player.getSprite().Stop();
}



So hopefully someone can help me
If more code is needed ill post it all

Pages: [1]
anything