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


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.

  • \$\begingroup\$ Thanks a lot for the answer, I will checkout that algorithm and tell you about it later. \$\endgroup\$ – oscar.rpr Dec 5 '11 at 14:35
  • \$\begingroup\$ 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. \$\endgroup\$ – oscar.rpr Dec 10 '11 at 14:02
  • \$\begingroup\$ 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. \$\endgroup\$ – Ali1S232 Dec 10 '11 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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