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

Author Topic: Greater than or equal to location  (Read 1583 times)

0 Members and 1 Guest are viewing this topic.

GAMINGBACON97

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Greater than or equal to location
« on: September 04, 2015, 10:43:57 pm »
I'm wondering how I would find if something is farther than a certain position. here is my code:
sf::Vector2f PinkLocation=PinkPlayer.getPosition();
   if (PinkLocation >= sf::Vector2f(100, 100)){
                     //do stuff
      }
I know that it can't take the two numbers a time, but it there another way to do this?

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Greater than or equal to location
« Reply #1 on: September 04, 2015, 10:48:56 pm »
What exactly would you expect >= to do? Either number being bigger? Both bigger? Longer hypotenuse? Just write your own function that takes two Vector2fs.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Greater than or equal to location
« Reply #2 on: September 05, 2015, 01:11:24 am »
If it's a specific member, you simply just test that specific member you want to test (i.e. x or y).
If it's either number, you can test them both and OR them together.
If it's both, you can just test both and AND them together.

Why do you need to do this?
If it's to see if it's outside of a certain area, it might make more semantic sense (and possibly less code) to see if it's inside an sf::Rect instead.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

GAMINGBACON97

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Re: Greater than or equal to location
« Reply #3 on: September 05, 2015, 02:04:22 am »
how would I go about testing a specific number using x and y? and I need it so once you drag something off to a specific direction, then it will increment a score

GAMINGBACON97

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Re: Greater than or equal to location
« Reply #4 on: September 05, 2015, 02:10:30 am »
I think I figured out how to get a specific coordinate, like x or y, I will post an edit once I do some more testing to see if I can close this

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Greater than or equal to location
« Reply #5 on: September 05, 2015, 03:34:19 am »
how would I go about testing a specific number using x and y?
PinkLocation.x >= 100

I need it so once you drag something off to a specific direction, then it will increment a score
Is that direction to the right? Then test x. Is that direction to the bottom? Then test y.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

GAMINGBACON97

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Re: Greater than or equal to location
« Reply #6 on: September 05, 2015, 05:01:20 am »
Thx Hapax, with your help, and a bit of tweaking I got it working, Thx to all who helped!!!