Alright, I think it's time I posted my solution as an answer(thanks Byte56). It's not the prettiest but it works well enough for me.
I basically have a method for moving in the different directions. The goal variables are the tile we want to move to. In the next iteration of the game loop the entity's update method will take care of the goal variable.
/**
* Move the entity right.
*/
public void moveRight() {
if(goalY == y) {
goalX = x+1;
horizontalSpeed = speed;
// resetGoalY();
}
}
I got a bug with this method that I will fix later on but I think it's good if you get the bigger picture of how my movement works. As long as goalX != x we will update the offset on each axis with the given speed. Note that the two different speeds can either be negative or positive depending on what direction we want to go. I
then check if the offset equals the maximum offset (in my case, this is the tile size) and seeing as it can be either tilesize or -tilesize I will check with Math.abs which gives the absolute value of the values.
If the values are equal it's time for the logic to move to that tile and I then reset the offsets.
/**
* Update the entity's movement.
*/
private void updateMovement() {
if(map.isTileWalkable(goalX, goalY)) {
if(goalX != x) {
xOffset += horizontalSpeed;
}
else if(goalY != y) {
yOffset += verticalSpeed;
}
if(Math.abs(xOffset) == maxXOffset) {
resetXOffset();
x = goalX;
}
else if(Math.abs(yOffset) == maxYOffset) {
resetYOffset();
y = goalY;
}
}
}