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

Author Topic: bool sf::Sprite::CheckCollosion(Sprite param)  (Read 6491 times)

0 Members and 1 Guest are viewing this topic.

h2o202

  • Newbie
  • *
  • Posts: 4
    • View Profile
bool sf::Sprite::CheckCollosion(Sprite param)
« on: March 20, 2008, 01:12:41 pm »
I would like to have a simple method for collision detection just like shown above.
I know it's better to implement collision detection by myself, but i think collision detection is a often used operation with Sprite's, so why don't implement a method, or more, into the Sprite class?
There could be some different methods with different precisions, like pixelwise, rectangular, ...
I whould like to use this methods while writing my games, and if I see my game works, I can still implement my own collision detection for my specific needs.
What do you think about it?

And execuse my bad school english, I have to work on it :oops:
Sorry, My english is not so good ^^

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #1 on: March 20, 2008, 01:56:59 pm »
I'm thinking about adding some kind of intersection / visibility tests to drawables for next version. Still not sure about details for now.
Laurent Gomila - SFML developer

h2o202

  • Newbie
  • *
  • Posts: 4
    • View Profile
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #2 on: March 20, 2008, 03:48:18 pm »
OK, thanks for information :D
Sorry, My english is not so good ^^

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #3 on: March 21, 2008, 11:41:00 am »
Quote from: "Laurent"
I'm thinking about adding some kind of intersection / visibility tests to drawables for next version. Still not sure about details for now.


Isen't there already one for rectangles, shouldn't that be sufficient?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #4 on: March 21, 2008, 04:47:55 pm »
Quote
Isen't there already one for rectangles, shouldn't that be sufficient?

No, drawables can be more than an axis-aligned rectangle. They can be rotated, have transparent pixels, have several convex shapes, etc.
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #5 on: March 22, 2008, 11:13:29 am »
What about using shapes to detect collisions?
And maybe providing a function that generates shapes from the non-transparent part of an image.
Like sf::Shape sf::Sprite::GetCollisionOutline(int Quality), where the quality parameter determines how detailed the shapes end up.
And then use bool sf::Shape::Collide(const sf::Shape& Other) and bool sf::Shape::IsPointInside(int X, int Y).
Shapes are quite flexible and can adapt almost any 2d geometry.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #6 on: March 22, 2008, 11:33:19 am »
How do you build a collision outline from a sprite with random transparent pixels ?

And I think this interface would be too complicated for just simple collision tests.
Laurent Gomila - SFML developer

Lord Delvin

  • Jr. Member
  • **
  • Posts: 68
    • ICQ Messenger - 166781460
    • View Profile
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #7 on: March 22, 2008, 11:42:56 am »
Quote from: "Laurent"
How do you build a collision outline from a sprite with random transparent pixels ?

Forget about the outline I'd say...one could add alpha and check if it's at any point above 1...but that would be an expensive operation.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #8 on: March 22, 2008, 12:40:02 pm »
Quote from: "Laurent"
Quote
Isen't there already one for rectangles, shouldn't that be sufficient?

No, drawables can be more than an axis-aligned rectangle. They can be rotated, have transparent pixels, have several convex shapes, etc.
Yea, I guess it depends on what kind of game you are creating.

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #9 on: March 22, 2008, 03:09:19 pm »
Yep, maybe a function to generate collision outlines might be expensive.
But how to check on collisions between sprites otherwise (if not using just rectangles or pixel perfect collision detection)?
I have no idea...
Collision checking between shapes would still be a nice and useful feature, even if seen independent from the sprite issue.
Though I'm not sure how to implement it.

Quote

And I think this interface would be too complicated for just simple collision tests.

Sure, the implementation is complicated, but the interface itself?
I'm just curious what you are thinking of. :D
I guess I'll have to wait until you are done.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #10 on: March 23, 2008, 06:02:16 am »
I'm still not sure about the interface, I haven't started to implement it.
Laurent Gomila - SFML developer

aisman

  • Newbie
  • *
  • Posts: 25
    • View Profile
bool sf::Sprite::CheckCollosion(Sprite param)
« Reply #11 on: April 15, 2008, 11:37:42 am »
Quote from: "Laurent"
I'm still not sure about the interface, I haven't started to implement it.

Please start ;-)

 

anything