//VARIABLES
const float gravity = 9.81f;
const float force = 15.f;
bool isMoving = false;
sf::Vector2f velocity = { 0,0 };
//PLAYER.CPP
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { //movement
isMoving = true;
velocity.x -= force;
}
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
isMoving = true;
velocity.x += force;
}
else {
isMoving = false; //yeah i know its dumb
}
if (isMoving == false) { //deceleration
velocity.x *=0.9;
}
if (velocity.x > 400) //max x speed
velocity.x = 400;
if (velocity.x < -400)
velocity.x = -400;
player_sprite.getSprite("player").move(velocity*dt); //thats my sprite manager script