Implemented direction rotation for movement, to align with player view
This commit is contained in:
parent
875fab8c46
commit
beb87da14b
3 changed files with 4 additions and 4 deletions
|
@ -173,8 +173,8 @@ sf::Vector2f Direction::asIsometricVector() const
|
||||||
{
|
{
|
||||||
// Rotate vector by 45 degrees clockwise
|
// Rotate vector by 45 degrees clockwise
|
||||||
auto isometricVector = sf::Vector2f(0.0f, 0.0f);
|
auto isometricVector = sf::Vector2f(0.0f, 0.0f);
|
||||||
// Todo
|
|
||||||
isometricVector.x = directionVector.y + directionVector.x;
|
isometricVector.x = directionVector.y + directionVector.x;
|
||||||
isometricVector.y = directionVector.y + directionVector.x;
|
isometricVector.y = directionVector.y - directionVector.x;
|
||||||
|
|
||||||
return isometricVector / 2.f;
|
return isometricVector / 2.f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
sf::Vector2f asVector() const;
|
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
|
/// \return
|
||||||
sf::Vector2f asIsometricVector() const;
|
sf::Vector2f asIsometricVector() const;
|
||||||
sf::Vector2f asScreenVector() const;
|
sf::Vector2f asScreenVector() const;
|
||||||
|
|
|
@ -20,7 +20,7 @@ void Player::update(Game *game)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto moveDirection = input->direction.asVector();
|
auto moveDirection = input->direction.asIsometricVector();
|
||||||
auto moveDelta = moveDirection * 30.0f * FRAME_TIME.asSeconds();
|
auto moveDelta = moveDirection * 30.0f * FRAME_TIME.asSeconds();
|
||||||
coordinates.move(moveDelta);
|
coordinates.move(moveDelta);
|
||||||
circle->coordinates.set(coordinates);
|
circle->coordinates.set(coordinates);
|
||||||
|
|
Loading…
Reference in a new issue