SFML community forums
Help => General => Topic started by: GroundZero on September 04, 2011, 10:22:50 pm
-
Heya, im making a 2D RPG game somewhat like Maplestory.
Only thing is that my current collision system aint doing what I want it to do. It works but the accuracy aint perfect. Like the sample here:
_______________
| |
- |
| |
| |
| |
-------------------- -----------------------
You see a platform... only thing is that the top aint as width as the lower section of the platform, and thus the character would be walking in the air for a couple of pixels instead of falling off.
So I need a better collision system and -or library which is easy to use.
Does anyone have any suggestions or a sample code working in SFML 2.0 ? the one from wiki aint working (i think its 1.6 version?).
best regards
-
You can make the object out of multiple smaller objects like this:
_______________
| Object 1 |
-----------------|
| |
| Object 2 |
| |
-------------------- -----------------------
And then check for collision against both of them, otherwise you have to starting looking into "Pixel Perfect Collision". Which is much slower, but more accurate.
-
otherwise you have to starting looking into "Pixel Perfect Collision". Which is much slower, but more accurate.
Pixel perfect collision isn't really that slow if you do it right, currently for my platformer, im using a very unoptimal(slow) method to achieve it, and i still get maxfps without drops(1000).
If you want pixelperfect; Create a rect for your player, and generate collisionmaps for each tile you load(2d-vector of bool's would be something), then check if you playerrect intersects with your tilerects, if they do, check if any pixel collides between the playerrect and the tile-collisionmap, based off the intersected intersection that sf::Rect::Intersects returns
-
Maybe Box2D can help you.
It works well for me.
-
thanks for your replies guys, I will look into this :D
P.S. any tutorials on Collision with Box2D ?