First of all, I have done some research on this topic before asking, and I'm asking this question as a mean to get some opinions on this topic, so I don't make a decision only on my own, but taking into account other people's experience as well.

I'm starting a 2D online RPG project. I am using SFML for graphics and input and I'm creating a basic game structure and all for the game, creating modules for each part of the game.

Well, let me get to the point I just wanted to give you guys some context.

I want to decide on how I'm going to work with collision detection. Well I'm kinda going to work on maps with a tile map divided in layers (as usual) and add an extra 2 layers - not exactly in the map - for objects. So I'll have collisions between objects and agents (players - npcs - monsters - spells etc) and agents and tiles. The seconds one can be easily solved the first one need a little bit of work.

I considered both creating a basic collision test engine using polygons and a quadtree to diminish tests since I'm going to be working with big maps with lots of objects - creating both a physical and graphical world representation. And I also considered using a physics engine like Box2D for collision tests.

I think the first approach would take more work on my part but the second one would have the overhead of using a whole physics engine for just collision detection and no physics.

What do you guys think ?


1 Answer 1


For an RPG with tiled map, i think the best would be to use some really simple collision test with rectangular boxes. And then, when two rect intersect, for instance, the player and a blocking tile, you can do some pixel perfect collision on the intersection area to see if at least one pixel (or any other pixel tolerance) overlap.

Some old school RPG use a dedicated layer to determine if a tile is blocking or not on a map, it's just a simple bit array (0 non blocking and 1 blocking). For the dynamic entities, in some cases, you may want to use another shape like circle to be a bit more precise. Collision detection would be the same for tile than for entities, tile would be rect and entities would be any other simple shape.

Using a physics engine only for collision detection in an RPG would be a bit overkill to me.

  • \$\begingroup\$ Thanks for your comment, I do think this way as well, just wanted to confirm that, I will have simple collision tests as you said and some just a little more robust in order to have better movement since I'm going to use keyboard movement control and free movement not tile based, but thanks. \$\endgroup\$
    – PHMitrious
    Commented Sep 20, 2012 at 10:43
  • \$\begingroup\$ @PHMitrious if i have correctly answered your question, please mark it accepted. \$\endgroup\$
    – nathan
    Commented Sep 20, 2012 at 11:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .