SFML community forums
General => Feature requests => Topic started by: h2o202 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:
-
I'm thinking about adding some kind of intersection / visibility tests to drawables for next version. Still not sure about details for now.
-
OK, thanks for information :D
-
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?
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
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.
-
I'm still not sure about the interface, I haven't started to implement it.
-
I'm still not sure about the interface, I haven't started to implement it.
Please start ;-)