I'm making a game with C++ where the program extracts the lines out of an image (via openCV), stores them in an std::vector< std::vector< int > > and the builds a tile map out of it which is used for a simple jump'n'run game (with SFML).
Having everything else implemented, I still struggle when it comes to implementing the collision detection. I have tried several approaches (i. e. the second approach on this site) but always failed. This means that the player is able to move over obstacles as there was no collision detection.
So I need a simple, fail-safe way of implementing a collision detection (or maybe just the algorithm) when using a tile map.
I don't want my code or my former approach corrected, but I'm asking for a simple way to implement a collision detection in a 2d tile-based game.
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.
|
|||||||||||||||||||||
closed as unclear what you're asking by Anko, ktodisco, Byte56♦ Feb 4 at 15:18Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question. |
|||||||||||||||||||||
|
Heere are the generic steps, where are you stuck? Alright.
How to check for intersection between rectangles? Assuming these are the corners on the left side of your bounding box
The same works for every direction of movement. |
|||||||||
|