How to move one tile (Grid movement, like pokemon and zelda)

Hello,

i have made a simple game. But i would love to know, how to move 1 tile. Now the Player is “jumping” 3-4 tiles and speed is to fast and animation is not showing due to that.

Main Thread:
http://pastebin.com/meyahFUY

Player:
http://pastebin.com/5URYsrgt

Creature Abstract class:
http://pastebin.com/jLV7RkwV

Animation, i’m using this:

PositionVector:
http://pastebin.com/b5i469Vi

DirectionVector:
http://pastebin.com/4Dgx2Kew

Map:
http://pastebin.com/dFJAktqV

Camera:
http://pastebin.com/QjBX2tUR

I would appricate all the help!

You could try to set a destination

if (!moving){
            if (keys.W is down) {
                targetY = y + tileSize;
                moving = true;
            }
        } else {
         updateAnim
         }
        
if (x < targetX)x++;
if (x > targetX)x--;
if (y < targetY)y++;
if (y > targetY)y--;

I woud like to make it work, with my current setup :frowning: Problem is that, the player moves. But it moves couple tiles, i would like to move one tile per time.

then only move when you’ve reached your next tile

I’m already doing that, i think :stuck_out_tongue:

What I do is I keep the direction the player is moving towards stored in a variable. Then to get the smooth movement I interpolate between the position the player was standing and the position the player should move to. That way you get a nice movement, dependent on the delta and a specific speed. The player won’t accidently move over the tile and get stuck a few pixels off, since the final position per tile is already decided. Once the alpha, or percentage of the step is at 1.0, you check if any direction keys are pressed and you do the whole thing all over again. This is a very simple but efficient and smooth way of achieving what you want.

Thank you for your answer. Could you please present me with code examples based on my current setup. Since i’ve been dealing with this for couple days with no luck :frowning:

None?

Were you able to figure it out?