void Game::update(Time deltaTime)
{
if (m_keys_pressed[Keyboard::Up])
{
m_player_time = m_player_clock.getElapsedTime();
if (m_player_time.asSeconds() < (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(0, -SPEED / 2));
}
else if (m_player_time.asSeconds() >= (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(0, -SPEED / 2));
}
}
else if (m_keys_pressed[Keyboard::Down])
{
m_player_time = m_player_clock.getElapsedTime();
if (m_player_time.asSeconds() < (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(0, SPEED / 2));
}
else if (m_player_time.asSeconds() >= (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(0, SPEED / 2));
}
}
else if (m_keys_pressed[Keyboard::Left])
{
m_player_time = m_player_clock.getElapsedTime();
if (m_player_time.asSeconds() < (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(-SPEED / 2,0));
}
else if (m_player_time.asSeconds() >= (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(-SPEED / 2,0));
}
}
else if (m_keys_pressed[Keyboard::Right])
{
m_player_time = m_player_clock.getElapsedTime();
if (m_player_time.asSeconds() < (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(SPEED / 2,0));
}
else if (m_player_time.asSeconds() >= (TIME_DEPLACEMNT / 2))
{
m_joueur.increaseAnim();
m_joueur.move(Vector2f(SPEED / 2,0));
}
}
m_joueur.updateDirection(m_joueur.getDirection());
}
increaseAnim permet de passer a l animation suivante!