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

Author Topic: Rotation and movement...  (Read 5732 times)

0 Members and 1 Guest are viewing this topic.

Dummie

  • Newbie
  • *
  • Posts: 25
    • View Profile
Rotation and movement...
« on: March 21, 2008, 10:53:48 pm »
Hey,

Currently I'm checking out the possibillities to rotate a sprite. It works very great, but I got a question. Why the degree get with every turn +/-360?
I was wondering very much when I made a debug output with GetRotation() and saw a very big or very small value instead of something like 127...

In addition to that I'd like to build something like this:
http://www.tonypa.pri.ee/tbw/tut20.html

Could somebody provide me a code example that calculate the values I have to pass to SetLeft() and SetTop() to get the same result as on the page I posted above?

Thanks in advance :) :) :)


PS: If I rotate the sprite do I have to call this code again?
Code: [Select]

Sprite.SetRotationCenter(Sprite.GetHeight() / 2, Sprite.GetWidth() / 2);

Or is it done by SFML already?

Kingdom of Fish

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Rotation and movement...
« Reply #1 on: March 21, 2008, 11:23:30 pm »
You only have to set the center once.

Dummie

  • Newbie
  • *
  • Posts: 25
    • View Profile
Rotation and movement...
« Reply #2 on: March 23, 2008, 05:01:20 pm »
Thank you :)

But I still haven't a answer to my other question :)

Thanks in advance

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Rotation and movement...
« Reply #3 on: March 24, 2008, 05:17:55 pm »
Quote
Why the degree get with every turn +/-360?

Because there's no code to keep it in the range [0, 360] or [-180, 180] (or whatever you prefer). You can apply a modulo if you want to keep it in a specific range.

Maybe I'll have to do it on SFML side however, as accumulation with float numbers could cause a loss of precision.
Laurent Gomila - SFML developer

Aszarsha

  • Full Member
  • ***
  • Posts: 200
    • MSN Messenger - aszarsha@gmail.com
    • View Profile
Rotation and movement...
« Reply #4 on: March 24, 2008, 05:20:10 pm »
Quote from: "Laurent"
Maybe I'll have to do it on SFML side however, as accumulation with float numbers could cause a loss of precision.
It actually do, i've encoutered the problem a couple of times.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Rotation and movement...
« Reply #5 on: March 24, 2008, 05:34:09 pm »
Ok, rotations are now kept in the range [0, 360].
Laurent Gomila - SFML developer

 

anything