Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My team and I are developing a 2D platformer with C++/SDL/OpenGL, and we already defined a collision system, but we have a problem checking collisions with the tilemap.

The tiles of the tilemap are 32x32, so we try to define that the max speed in X and Y of the player it's less than 32 because in this case we found the problem that if the speed it's bigger than the tile size, when checking the collisions the position it's updated with the speed which it's more than 32, so in that case, the position skip a tile which causes a huge problem for verification, so at the momento we limit the X and Y speed to 30, but we don't know how make the speed bigger than the tile size without losing the complete collision detection with some possible tiles that may be skiped.

Thanks a lot

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The Easiest way is to update your world twice(or more) every cycle. using this method you can increase your max speed 2 or more times.

The more Universal way to do it but is to check collision of the shape generated by the moving object, with all the tiles. something like the picture below while red box moves collision is checked for every square in map and the blue area (which is a polygon generate by convex hull algorithm):

collision sample

physic engines usually have a support for such a feature, to check continues space for movement. for example in box2d there is a member (isBullet) which indicates if engine should use continues movement checking.

share|improve this answer
    
Thanks a lot for the answer, I will checkout that algorithm and tell you about it later. –  oscar.rpr Dec 5 '11 at 14:35
    
Thanks for the answet. I already use a sweep test algorithm which it's working really greay, anyhow I will have in mind this algorithm for future projects. –  oscar.rpr Dec 10 '11 at 14:02
    
well, what I said was just using sweep algorithm for any polygon, or at least how I know sweep is implemented for none trivial shapes. –  Ali.S Dec 10 '11 at 17:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.