Implemented direction rotation for movement, to align with player view

This commit is contained in:
Maximilian Giller 2023-05-20 17:08:47 +02:00
parent 875fab8c46
commit beb87da14b
3 changed files with 4 additions and 4 deletions

View file

@ -173,8 +173,8 @@ sf::Vector2f Direction::asIsometricVector() const
{
// Rotate vector by 45 degrees clockwise
auto isometricVector = sf::Vector2f(0.0f, 0.0f);
// Todo
isometricVector.x = directionVector.y + directionVector.x;
isometricVector.y = directionVector.y + directionVector.x;
isometricVector.y = directionVector.y - directionVector.x;
return isometricVector / 2.f;
}

View file

@ -31,7 +31,7 @@ public:
public:
sf::Vector2f asVector() const;
/// \brief Returns a vector that is rotated to accommodate isometric projection
/// \brief Returns a vector that is rotated to accommodate isometric projection that can be used for movement from the players point of view.
/// \return
sf::Vector2f asIsometricVector() const;
sf::Vector2f asScreenVector() const;

View file

@ -20,7 +20,7 @@ void Player::update(Game *game)
return;
}
auto moveDirection = input->direction.asVector();
auto moveDirection = input->direction.asIsometricVector();
auto moveDelta = moveDirection * 30.0f * FRAME_TIME.asSeconds();
coordinates.move(moveDelta);
circle->coordinates.set(coordinates);