Well, the hit detection is getting there, but I'm still finding myself able to go through walls and not be able to get into narrow gaps when falling and jumping...
Here's a basic synopsis of what I'm doing:
-A room is 16x12. There's an array that holds the various block types (0 for solid, 1 for blocking, 2 for spike)
-A player's hitbox is 16x16.
-I've got 4 variables: 2 for your X/Y coords and 2 more for an X/Y offset.
-The X/Y offset is setup so that 16 is center. When it either = 0 or 32, you've gone entirely into the next adjacent block and your X/Y coords will change.
-Whenever a player's offset is not 16, then you need to take into account some adjacent blocks.
-The order I check things in is walking, jumping, falling.
It doesn't check if you're INSIDE a solid block, but only if you tried to move into one. One example is if you walk out the right side and the next room has a solid block at the point of entry on the left, you can walk freely while inside that block, but if you walk off the block, you can't walk into it.
Does this approach sound reasonable or is there anything that stands out that should be looked at?
Here's a basic synopsis of what I'm doing:
-A room is 16x12. There's an array that holds the various block types (0 for solid, 1 for blocking, 2 for spike)
-A player's hitbox is 16x16.
-I've got 4 variables: 2 for your X/Y coords and 2 more for an X/Y offset.
-The X/Y offset is setup so that 16 is center. When it either = 0 or 32, you've gone entirely into the next adjacent block and your X/Y coords will change.
-Whenever a player's offset is not 16, then you need to take into account some adjacent blocks.
-The order I check things in is walking, jumping, falling.
It doesn't check if you're INSIDE a solid block, but only if you tried to move into one. One example is if you walk out the right side and the next room has a solid block at the point of entry on the left, you can walk freely while inside that block, but if you walk off the block, you can't walk into it.
Does this approach sound reasonable or is there anything that stands out that should be looked at?