Alright... I have done everything in my power to fix this but it turns out.... I can't fix it.
Basically I call a check to see if a button on the keyboard is pressed and which button is being pressed.
Then it does what it is supposed to do(Move player left or right), And it works... BUT!
When ever I move the mouse, it does the same thing(Move the player to the right).
Does the problem rely on the mouse I am using(Razer - Black Mamba) or am I an idiot?
Here is a snippet of my code:
if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::D))
{
//Move to the Right and shift one frame on the animation tile
Player::FrameSize.left = 32 * Player::frame;
Player::FrameSize.top = 0;
Player::VELx += 0.01;
}
if((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::A))
{
//Move to the Left and shift one frame on the animation tile
Player::FrameSize.left = 32 * Player::frame;
Player::FrameSize.top = 32;
Player::VELx += -0.01;
}
if((event.type == sf::Event::KeyReleased) && (event.key.code != sf::Keyboard::D))
{
//if button is not being pushed... Reset the animation
Player::FrameSize.left = 0;
Player::VELx = 0;
Player::clock.restart();
}
if((event.type == sf::Event::KeyReleased) && (event.key.code != sf::Keyboard::A))
{
//if button is not being pushed... Reset the animation
Player::FrameSize.left = 0;
Player::VELx = 0;
Player::clock.restart();
}
Oh and also... Note that the VEL stuff is not 100% thought through yet, I needed to test the movement of the sprite and its animation.
As for the "(event.type == sf::Event::KeyReleased)" and "(event.type == sf::Event::KeyPressed)", has no effect if it was like:
if(event.type == sf::Event::KeyPressed){
if(event.key.code == sf::Keyboard::D)
{
Player::FrameSize.left = 32 * Player::frame;
Player::FrameSize.top = 0;
Player::VELx += 0.01;
}
if(event.key.code == sf::Keyboard::A)
{
Player::FrameSize.left = 32 * Player::frame;
Player::FrameSize.top = 32;
Player::VELx += -0.01;
}
}
Any insight or fix or anything would be most greatly appreciated.