I'm currently trying to handle collisions between entities and a tilemap, but I've hit a problem. My tiles are stored simply as integer tile IDs in a multidimensional array, and I wanted to perform a quick collision check by working out which tile the player is on (or will be on if the new position is valid), by simply dividing the player's position by the tile size to get the x,y of the tile in question. After this, I'd perform a simple SDL_Rect collision check between the tile's rect and the entity's.
The problem of course is that depending on which direction I'm moving in, I may want to add the entity's width/height to the x,y position of the entity when working out which tile I'm on, otherwise the collision would only apply to the top left corner of the entity. I tried to do this myself, but couldn't produce consistent results. I didn't think it would be difficult, but I'm obviously missing something.
In my situation, my entity sprites are 32x32, while tiles are 16x16. Is it possible that using tiles that are smaller than my entity is making it more of a problem than it might otherwise be?
Thanks in advance for any help you can offer in suggesting a working solution.