Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why is movement logic inverted for y axis?  (Read 1423 times)

0 Members and 1 Guest are viewing this topic.

firepro20

  • Newbie
  • *
  • Posts: 22
    • View Profile
Why is movement logic inverted for y axis?
« on: November 16, 2019, 02:51:53 pm »
I am following the book SFML Game Development, and noticed to go up or down, logic is inverted.

sf::Vector2f movement(0.f, 0.f);
   if (mIsMovingUp)
      movement.y -= PlayerSpeed;
   if (mIsMovingDown)
      movement.y += PlayerSpeed;

And it works!

Is there a reason for this? Thanks in advance

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Why is movement logic inverted for y axis?
« Reply #1 on: November 16, 2019, 07:40:13 pm »
It's just convention, and it's not unusual. In SFML the y axis increases downwards.

firepro20

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Why is movement logic inverted for y axis?
« Reply #2 on: November 17, 2019, 12:14:00 am »
Ok thanks did not know that!

 

anything