1
\$\begingroup\$

I'm building a game in C/C++ (been alternating between the two), but one of the biggest problems I've run into is collision detection. The game is isometric and exists on a 2x1 grid (e.g. the base tile is 32x16px).

Most creatures in the game use ellipses as collision masks (similarly 2x1 sized, default size is 32x16), whereas static objects use rhombuses for masks (again, 2x1, 32x16 default). How do I detect the collision of these two distinct shapes? Also, how do I detect collisions between two ellipses and/or two rombuses?

I've looked at the Separating Axis Theorem, Voronoi diagrams, and all kinds of other things, but I am having trouble understanding them (which is a pretty essential step for C/C++). Can anyone help me to understand these techniques?

\$\endgroup\$
  • 3
    \$\begingroup\$ Remember that the shape you draw to the screen doesn't have to be the shape your world "is". Isometric games often represent a world with a regular square grid, and just project it to the diamond form for display purposes to model looking at the scene obliquely. Sticking in pre-projections space can make a lot of your math simpler & more uniform (eg. circles & squares instead of ellipses & rhombuses) \$\endgroup\$ – DMGregory Oct 4 '17 at 22:39
  • \$\begingroup\$ Along the lines of @DMGregory 's comment about simplifying things by utilizing the internal game model instead of relying on the rendering shapes, I wonder if you're able to disregard the geometric calculations entirely. Might it be sufficient for your purposes to simply treat it as "player wants to move to cell [x,y], is that cell already occupied?" \$\endgroup\$ – A C Oct 4 '17 at 23:12
  • \$\begingroup\$ I was considering going with that model, but my game doesn't snap to the grid. Since it's an open-world RPG with fairly free movement, I feel like my players will feel cheated if they don't get good collision. How much of a performance hit am I really looking at with these kind of collisions? \$\endgroup\$ – WulffHunter Oct 5 '17 at 4:21

Your Answer

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

Browse other questions tagged or ask your own question.