SFML community forums
Help => Graphics => Topic started by: blueeyedlion on October 06, 2011, 03:56:15 am
-
What is the correct way to create a green square that is 15 * 15 pixels, and rotate it 180 degrees around its exact centre pixel?
I seem to be getting something wrong.
-
Can you show us your code first? ;)
-
sf::Shape rect = sf::Shape::Rectangle (1, 1, 15, 15, sf::Color::Green);
rect.SetCenter (7, 7);
rect.Rotate (180);
-
This is exactly what you described. So what's wrong?
-
The code you posted is fine--it's just that since the shape is an equiangular square, turning it 180 degrees is not going to change how it looks.
If you want it to progressively rotate to 180 degrees, that's a different story. The simplest way I can think of would be:
//Drawing loop
if (rect.GetRotation() < 180) {
rect.Rotate(1.f);
}
-
The problem is that the square from my code ends up to be 14x14 pixels.
I counted the pixels with my digital microscope to be sure.
-
In SFML 1.6, the 3rd and 4th arguments of sf::Shape::Rectangle are the coordinates of the bottom-right corner, not the width/height.
-
Is that to say it's different in another version of SFML?
-
In SFML 2 these arguments are width and height.
-
That sounds much better, when is it going to be released?
-
That sounds much better, when is it going to be released?
SFML2 is already "out," but you need to get the source from github and compile it yourself.
-
where can I find a step by step guide for doing that?
-
Well, anyone noticed he set the rect starting from 1x1, wich subtracts 1x1 from the resulting size.
-
THANK YOU!