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

Author Topic: Simple Collision Detection -> SFML2  (Read 5058 times)

0 Members and 1 Guest are viewing this topic.

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying
Simple Collision Detection -> SFML2
« on: June 25, 2012, 04:49:31 am »
ON the wikie is a cool collision tester
https://github.com/SFML/SFML/wiki/SourceSimpleCollisionDetection

but it is not SFML2.. I went to try and update it but some of teh function are not in sfml2 as far as I know.. like "TransformToGlobal" ... is there ea version of that under a new name in sfml2?

TransformToGlobal
GetSize

Dose anyone know the sfml2 alternative to these?

Dose anyone have this code updated for SFML2?

Thanks in advance

« Last Edit: June 25, 2012, 04:52:09 am by aNewHobby »
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Re: Simple Collision Detection -> SFML2
« Reply #1 on: June 25, 2012, 06:07:31 am »
GetSize() was probably replaced by getSize(). Note the lower case, this is true of all functions in SFML2. The coordinate conversion functions have been renamed to convertCoords() and are part of RenderWindow.

Remember you can find this stuff in the SFML 2.0 Documentation
« Last Edit: June 25, 2012, 06:17:45 am by thePyro_13 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Simple Collision Detection -> SFML2
« Reply #2 on: June 25, 2012, 09:20:06 am »
GetSize() was probably replaced by getSize(). Note the lower case, this is true of all functions in SFML2. The coordinate conversion functions have been renamed to convertCoords() and are part of RenderWindow.

No?
Linking the documentation and not looking at it is kind of ironical... :P

convCoord() converts a coordinate from the render target coordinate system to the view coordinate system. It's similar but this concerns the view transformations and not the sprite transformation...

In SFML 2.0 you now got the class Transform with which you can transform anything and the sprite class has a function getTransform() to get the transform object of the sprite class.
sf::Vector2f point = transform.transformPoint(sprite.getTransform());

As for the GetSize() you now have getLocalBounds().
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Re: Simple Collision Detection -> SFML2
« Reply #3 on: June 25, 2012, 09:49:35 am »
Whoops, silly me. I'll let myself out. :p

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying
Re: Simple Collision Detection -> SFML2
« Reply #4 on: June 25, 2012, 10:11:17 am »
so...

float Radius1 = (Object1.GetSize().x + Object1.GetSize().y) / 4;

becomes

float Radius1 = (Object1.getLocalBounds().width + Object1.getLocalBounds().height) / 4;

and...

In SFML 2.0 you now got the class Transform with which you can transform anything and the sprite class has a function getTransform() to get the transform object of the sprite class.
sf::Vector2f point = transform.transformPoint(sprite.getTransform());

is the code you gave the same as this old code?
sf::Vector2f pos = Object.TransformToGlobal(sf::Vector2f(0, 0));
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Simple Collision Detection -> SFML2
« Reply #5 on: June 25, 2012, 10:28:16 am »
Whoops, silly me. I'll let myself out. :p
;D

In SFML 2.0 you now got the class Transform with which you can transform anything and the sprite class has a function getTransform() to get the transform object of the sprite class.
sf::Vector2f point = transform.transformPoint(sprite.getTransform());

is the code you gave the same as this old code?
sf::Vector2f pos = Object.TransformToGlobal(sf::Vector2f(0, 0));

What were I thinking when writing this... But it should've been really easy for you to figure out with the documentation how to use it. ;)

SFML 1.6
sf::Vector2f pos = Object.TransformToGlobal(sf::Vector2f(0, 0));

SFML 2.0
sf::Transform = Object.getTransform();
sf::Vector2f pos = transform.transformPoint(sf::Vector2f(0, 0));

When you're done with the conversion, will you add it to the wiki?
« Last Edit: June 25, 2012, 10:30:14 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying
Re: Simple Collision Detection -> SFML2
« Reply #6 on: June 28, 2012, 05:17:40 am »
When you're done with the conversion, will you add it to the wiki?
I ended up not using it. I think I should have, but I couldn't get it to work so wrote my own and it is pretty bad. What I needed was a circle test vs a rectangle.
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)