Implemented movement skewing
This commit is contained in:
parent
7b1a357998
commit
ce270864b2
2 changed files with 8 additions and 2 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
// Graphic settings
|
// Graphic settings
|
||||||
#define ISOMETRIC_SKEW 0.3f
|
#define ISOMETRIC_SKEW 0.3f
|
||||||
|
#define MOVEMENT_SKEW sf::Vector2f(1.f, 1/ISOMETRIC_SKEW/2.f)
|
||||||
#define WORLD_TO_ISO_SCALE 10.0f
|
#define WORLD_TO_ISO_SCALE 10.0f
|
||||||
|
|
||||||
// Tracking view defaults
|
// Tracking view defaults
|
||||||
|
|
|
@ -171,10 +171,15 @@ void Direction::setY(float value)
|
||||||
|
|
||||||
sf::Vector2f Direction::asIsometricVector() const
|
sf::Vector2f Direction::asIsometricVector() const
|
||||||
{
|
{
|
||||||
|
auto skewedDirection = sf::Vector2f(
|
||||||
|
directionVector.x * MOVEMENT_SKEW.x,
|
||||||
|
directionVector.y * MOVEMENT_SKEW.y
|
||||||
|
);
|
||||||
|
|
||||||
// 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);
|
||||||
isometricVector.x = directionVector.y + directionVector.x;
|
isometricVector.x = skewedDirection.y + skewedDirection.x;
|
||||||
isometricVector.y = directionVector.y - directionVector.x;
|
isometricVector.y = skewedDirection.y - skewedDirection.x;
|
||||||
|
|
||||||
return isometricVector / 2.f;
|
return isometricVector / 2.f;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue