So, I've been quite lost in this matter for a few days and hoped someone can clarify this thing for me as my math sucks :x
Here is a screenshot of a game I'm making to learn about gosu:
The numbers on the tiles are X / Y of their coordinates in an array[y][x] that describes each tile passability (I did not draw the map by tiles, I just loaded an image).
The blue boxes around the player are his collision boxes (for the sake of this post just consider the light blue one).
The pink tiles are the ones I'm testing the collisions, you can disregard them.
After hours and hours of suffering I could make the code that detects if the player (or any entity) had collided with an specific tile. Setting aside the fact that my way is certainly not the most effective way of doing it, I have two problems:
1. I need to know the axis in which the player collided with the tile (so I can block his movement just on this axis).
2. I need to know in which tile (or which tiles) the player is in so I can calculate the collision with adjacent tiles in the event of his movement.
Also I'm using a rectangular collision box for the player which I'm not certain if is the most efficient way of doing it.
If anyone have an idea on how to do it, please share with me :)