Evaghetti wrote:

But then i need to ask: how would i check if there's something on pixel 60, 50 for example? Every time i think about it i just go back to the tile base collision

Well, you absolutely have to check the tiles at some point, we're just suggesting you do it as late as possible. Instead of converting the sprite's top left corner into tile space and doing all in that space, find all 4 corners in pixel space and then convert those to tile space separately.

For example, if Mario's top left corner is at (60, 50) and he's 16x16 pixels large, the other points will be at (75, 50), (60, 65) and (75, 65). Converting those 4 pairs to tile space (i.e. dividing by 8) you get (7, 6), (9, 6), (7, 8) and (9, 8). So, if Mario's moving down, you can check all tiles between (7, 8) and (9, 8). If any of those is solid, you have to eject Mario up.

Similarly, if moving right, you have to check all tiles between (9, 6) and (9, 8). If any of those is solid, eject Mario left.

The exact amount of pixels to eject can be calculated using the pixel coordinates, which will tell you how far into the solid block the sprite went.

When moving right or down, the first pixel inside the block is pixel 0, in which case you need to eject 1 pixel. The second pixel inside the block is pixel 1, in which case you need to eject 2 pixels. From that we conclude that the amount to eject when moving right is

`(RightX AND 7) + 1`. The AND is there to get rid of the bits we don't need. We don't need to know which tile the X coordinate is in (we already used that information before), we need to know how far into the tile the coordinate is. The formula when moving down is the same, but using BottomY instead, obviously.

When moving up or left, things are a bit backwards: the first pixel inside a tile is pixel 7, in which case we eject 1 pixel. The second pixel inside a tile is pixel 6, in which case we eject 2 pixels. From that we conclude that the amount of pixels to eject is

`8 - (LeftX AND 7)`. Same thing for up, but using TopX, obviously.