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

Author Topic: Comparing Coordinates  (Read 2967 times)

0 Members and 1 Guest are viewing this topic.

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
Comparing Coordinates
« on: August 27, 2009, 06:23:44 pm »
Hello Commnutiy ;)

I have another problem today and
it would be really gentil if u help me. :D

i wated to code a background and a sprite on it.no prob.
but now, i need to compare the coordinates so that the
sprite isnt able to go over the background.u understand?
the background has a size and if the player go over the map
he will maybe try to go over this size.

i looked in the docs  but there are only functions to flip or
to set the sprite.setting would be useful if i know the coords.
pls help.


Ancient

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Comparing Coordinates
« Reply #1 on: August 27, 2009, 06:29:02 pm »
I dont understand very well what you are asking, but if you want to find the coordinates of ur sprite, you can use the GetPosition function.

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
Comparing Coordinates
« Reply #2 on: August 27, 2009, 06:33:28 pm »
Quote from: "Devil0150"
I dont understand very well what you are asking, but if you want to find the coordinates of ur sprite, you can use the GetPosition function.


ty at first. yeah youm are right i didn't know to
write that in english but that what you have written is a good idea.
But i need something to compare the position.i think .GetPosition
does only give out the pos. with 'return MyPosition'.
now u understand my question?


Ancient :wink:

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Comparing Coordinates
« Reply #3 on: August 27, 2009, 06:53:45 pm »
You want to stop ur sprite from going out of the screen when moving, is that right? If thats what you want, u could use something like this.

Code: [Select]
if (mySprite.GetPosition().y > myWindow.GetWidth())
    {
          // sprite stops moving
     }

If thats not what you wanted, tell me with what u want to compare the sprite coordinates.

Edit: Tell me where are you from and maybe I can speak ur language.

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
Comparing Coordinates
« Reply #4 on: August 28, 2009, 02:43:18 pm »
Quote from: "Devil0150"
You want to stop ur sprite from going out of the screen when moving, is that right? If thats what you want, u could use something like this.

Code: [Select]
if (mySprite.GetPosition().y > myWindow.GetWidth())
    {
          // sprite stops moving
     }

If thats not what you wanted, tell me with what u want to compare the sprite coordinates.

Edit: Tell me where are you from and maybe I can speak ur language.


oh yeah that's it.
exactly what i needed :D
thanks a lot.
but now i have another question =)
while i was working with SDL, there were a
function which starts an animation of a sprite.
do u know the same in sfml?
ps:i am from germany ;)

Ancient

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Comparing Coordinates
« Reply #5 on: August 28, 2009, 04:34:20 pm »
Animation isn't handled by SFML. SFML isn't a game engine. :)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Comparing Coordinates
« Reply #6 on: August 28, 2009, 06:53:16 pm »
Quote from: "Tank"
Animation isn't handled by SFML. SFML isn't a game engine. :)
But as the SFML community is a good one there are some Animation engine on the official wiki, ( among them mine  8)   ) .
SFML / OS X developer

 

anything