Little Problem with player movement

Hi, my game is a maze with tiles, their dimension is 32*32 pix.

'cause my player sprite is 32*32… when I move it I’ve some problem to pass through the corridors
if the sprite is not perfectly positioned.

How I can resolve this drawback using 32*32 images size??

You can solve this by moving the player indirectly. That is… the “proxy” gets some input for moving right, but its not possible at this position… so it will move down instead until the way is clear.

http://kaioa.com/k/proxymove.png

If the center would be a tad higher it wouldnt move at all. (The “side step” direction apparently depends on the position of the center.)

If the player moves exactly 1 unit per frame the implementation is very straightforward. If you move several units, however, you have to check how far you have move down to clear the way… move that far and then to the desired direction for the remaining units.

So if I’m reading that right, the branch the player is attempting to move into with “suck” him in a bit, to help him transistion into the new corridor? If that is the case, then there’s got to be a point where pressing right just means you don’t move at all since there is a wall there, and a point where pressing right means the tiny ‘suction’ effect.

So if I’m reading that right, the branch the player is attempting to move into with “suck” him in a bit, to help him
transistion into the new corridor?

Yes. Some games use some friction for the sliding part, but I wouldnt use it in this case, because it isnt a 1:1000 thing.

If that is the case, then there’s got to be a point where pressing right just means you don’t move at all since
there is a wall there[…]

Yes, if the center point is next to a wall nothing would happen. (Imagine its some diamond shaped thingy.)

And well… usually the animation, which matches the wish direction is displayed. Eg pressing right will always show that walk right animation… even if the proxy makes the player move up or down or not at all.

so, when I move my player I check if the new location is accessible or blocked.
if it’s blocked I check if the image’s center can move in that direction.
if yes I’ll add the amount of pixel necessary to move the player in the desidered direction.

Little problem!!

If my player is on this case:

http://kaioa.com/k/proxymove.png

how I can determine that my player was moving downward if now my direction is EST?

without this information I can’t understand if add or remove pixel

how I can determine that my player was moving downward if now my direction is EST?

~how I can determine that my player should move downward if the player presses right? (I guess… ???)

See the red thing in the middle? Its the center marker. As you can see the center is below that corner, which is in the way. Therefore we make it move down to evade it. As you can see its 2 units down to clear the way. So, if we would move 5 units per frame, we would go down 2 units (for clearing the way) and then 3 units to the right.

If we would be one unit higher, the way would be blocked and we wouldnt move at all.

I had just understood this concept!!

also in this image I have to move the sprite to allow the movement to right, but in this case I’ve to remove y pixel.

My question was:

How I can determine if I’ve to add or remove pixels!

I was thinking to verify where I’m trying to move, for ex: NORTH
then I check if my right superior angle of my sprite can move on this direction, I remove x pixels
else I add pixels