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

Author Topic: Some clarification please  (Read 3950 times)

0 Members and 1 Guest are viewing this topic.

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Some clarification please
« Reply #1 on: October 06, 2011, 07:49:51 am »
Can you show us your code first? ;)
Laurent Gomila - SFML developer

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« Reply #2 on: October 08, 2011, 07:08:13 pm »
Code: [Select]
sf::Shape rect = sf::Shape::Rectangle (1, 1, 15, 15, sf::Color::Green);
rect.SetCenter (7, 7);
rect.Rotate (180);

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Some clarification please
« Reply #3 on: October 08, 2011, 10:07:42 pm »
This is exactly what you described. So what's wrong?
Laurent Gomila - SFML developer

Mikebissle

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - freezingblue
    • Yahoo Instant Messenger - mikebissle
    • View Profile
Some clarification please
« Reply #4 on: October 08, 2011, 10:41:37 pm »
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:

Code: [Select]

//Drawing loop
if (rect.GetRotation() < 180) {
  rect.Rotate(1.f);
}

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« Reply #5 on: October 10, 2011, 08:46:02 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Some clarification please
« Reply #6 on: October 10, 2011, 10:18:23 pm »
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.
Laurent Gomila - SFML developer

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« Reply #7 on: October 10, 2011, 10:29:46 pm »
Is that to say it's different in another version of SFML?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Some clarification please
« Reply #8 on: October 10, 2011, 10:33:44 pm »
In SFML 2 these arguments are width and height.
Laurent Gomila - SFML developer

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« Reply #9 on: October 10, 2011, 11:52:57 pm »
That sounds much better, when is it going to be released?

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Some clarification please
« Reply #10 on: October 11, 2011, 12:53:56 am »
Quote from: "blueeyedlion"
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.
I use the latest build of SFML2

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« Reply #11 on: October 11, 2011, 05:47:03 am »
where can I find a step by step guide for doing that?

Haikarainen

  • Guest
Some clarification please
« Reply #12 on: October 11, 2011, 06:10:14 am »
Well, anyone noticed he set the rect starting from 1x1, wich subtracts 1x1 from the resulting size.

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Some clarification please
« Reply #13 on: October 11, 2011, 04:51:15 pm »
THANK YOU!