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

Author Topic: sf::Mouse::getPosition mis-understanding  (Read 2292 times)

0 Members and 1 Guest are viewing this topic.

Garry_pro

  • Newbie
  • *
  • Posts: 13
    • View Profile
sf::Mouse::getPosition mis-understanding
« on: May 03, 2015, 11:35:59 am »
Hey, I'm making my first game with SFML, and for one part I need to rotate a sprite depending on the position of the mouse (local to window). The bit I dont quite understand is how you compare the position to another position, if ya get what I mean? I know what I have attempted below probablly doesn't make sense and is a bit random, but as I said this is my first game and I'm only a newbie.
sf::Vector2i mousepos = sf::Mouse::getPosition(window); // get the local position if the mouse

if (mousepos = (sf::Vector2i(-500, -100))
{
player.rotate(90);
}


 
« Last Edit: May 03, 2015, 11:37:49 am by Garry_pro »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10879
    • View Profile
    • development blog
    • Email
AW: sf::Mouse::getPosition mis-understanding
« Reply #1 on: May 03, 2015, 11:43:36 am »
You compare it with the comparison operator, that is: ==
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Garry_pro

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: AW: sf::Mouse::getPosition mis-understanding
« Reply #2 on: May 03, 2015, 11:50:47 am »
You compare it with the comparison operator, that is: ==

Aha, why didn't I think of that xD Thanks

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: AW: sf::Mouse::getPosition mis-understanding
« Reply #3 on: May 03, 2015, 11:53:08 am »
Aha, why didn't I think of that xD
Maybe you need to read a bit further in your C++ book ;)

By the way, are you sure you want to check for equality with one position? Clicking a single pixel will be rather difficult and annoying for the user.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Garry_pro

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: AW: sf::Mouse::getPosition mis-understanding
« Reply #4 on: May 03, 2015, 01:40:52 pm »
Aha, why didn't I think of that xD
Maybe you need to read a bit further in your C++ book ;)

By the way, are you sure you want to check for equality with one position? Clicking a single pixel will be rather difficult and annoying for the user.

I'm still learning, It must of simply been a human error :P