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

Author Topic: Is it possible to draw FloatRects to the screen?  (Read 2201 times)

0 Members and 1 Guest are viewing this topic.

dotty

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Is it possible to draw FloatRects to the screen?
« on: January 22, 2012, 07:34:31 pm »
As the title suggests, I'm using FloatRects for some collision detection. Is it possible to draw these to the screen so I can see their positions? I know I could simple copy the attributes of said FlaotRect then create a Shape, but I'm wondering if it's possible without the need of using Shape.

Thanks!

julen26

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
    • http://julen26.blogspot.com
Is it possible to draw FloatRects to the screen?
« Reply #1 on: January 22, 2012, 07:38:19 pm »
If you are using SFML 2 you can use sf::Vertex class. If not, I think that sf::Shape is the unique option (unless you use openGl directly).

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
Is it possible to draw FloatRects to the screen?
« Reply #2 on: January 22, 2012, 07:45:03 pm »
sf::RectangleShape
?

julen26

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
    • http://julen26.blogspot.com
Is it possible to draw FloatRects to the screen?
« Reply #3 on: January 22, 2012, 07:56:30 pm »
Quote from: "Elgan"
sf::RectangleShape
?


Omg, I have not noticed about that class until now :lol:
Sorry, anyway it's a sf::Shape based class.

dotty

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Is it possible to draw FloatRects to the screen?
« Reply #4 on: January 22, 2012, 08:21:46 pm »
but RectangleShape doesn't have the methods like Intersect and Contains though.

texus

  • Hero Member
  • *****
  • Posts: 501
    • View Profile
    • TGUI
    • Email
Is it possible to draw FloatRects to the screen?
« Reply #5 on: January 22, 2012, 08:35:26 pm »
Quote
but RectangleShape doesn't have the methods like Intersect and Contains though.

Just use your FloatRect for collision detection and create a RectangleShape from it when drawing:

Code: [Select]
sf::RectangleShape shape(sf::Vector2f(rect.Width, rect.Height));
shape.SetPosition(rect.Left, rect.Top);
window.Draw(shape);
TGUI: C++ SFML GUI

dotty

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Is it possible to draw FloatRects to the screen?
« Reply #6 on: January 22, 2012, 08:39:14 pm »
I guess that's the only way to do it. Ok, thanks.