Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a reasonable easy way to implement free movement in a tile-based isometric game? Meaning that the player wouldn't just instantly jump from one tile to another or not be "snapped" to the grid (for example, if the movement between tiles were animated but you'd be locked from doing anything before the animation finishes). I'm a really beginner with anything related to game programming, but with the help of this site and some other resources it was quite easy to do the basic stuff, but I haven't been able to find any useful resources for this particular problem.

Currently I've improvised something close to this: (WASD movement). The idea for the movement was to use the mouse map to detect when the player has moved to a different tile and then flip the offsets, and for the most part it works correctly (each corner makes the player move to wrong location: see, which is probably because I couldn't get the full mouse map work properly), but I have no illusions that it is even close to a good/sane solution. And anyway, it's mostly just to demonstrate what kind of a thing I'd like to implement.

share|improve this question
That code looks great, what is the problem exactly? You are pretty modest (in a good way) your code seems rather good, what feature is missing in the demo? – zehelvion Sep 28 '12 at 23:45
What I meant by the corner problems was this kind of behavior: . I haven't been able to come up with any other solution other than making a lot of if-checks for the problematic offsets, and even then there's some special cases where the player warps to a wrong location. But like I said, I was wondering how this kind of movement is usually implemented since I haven't seen the method I came up with used anywhere else. – xtr486 Sep 29 '12 at 0:22
up vote 10 down vote accepted

First of all I suggest that you change directions from: W - up-left S - down-right A - down-left D - top-right

into more intuitive: W - up S - down A - left D - right

As for your concern, I suggest that you make two functions, one translating isometric tile coordinates into grid coordinates, and second the other way around. That way you could simply separate MVC and it would make your life easier when computing active tile: enter image description here

share|improve this answer
Your answer looks really promising, but I admit quite much of it just goes over my head. However, I'll try to continue digesting your solution during the next few days. Is this anywhere close to what you were after? It does have some logic errors (off by one etc. ) and such, but as far as I know the top-down and isometric maps have the same movement. What I haven't even gotten around is how to translate the tile offset from top-down to isometric.. – xtr486 Sep 30 '12 at 22:58
That looks fine so far! I'll look into it on evening. The thing is to apply transformations in isometric tile drawing method into positionToUser () translate function, and inverse it in positionFromUser () method. – Markus von Broady Oct 1 '12 at 7:36
I see the problem: you're drawing izometric view by putting images instead of using canvas drawing API. It's quite logical, as in the end your izo tiles will be much more then a solid colour. However, for debugging you should also draw lines between the tiles, that would make your life much easier. Anyway, I forked your code and created positionToUser(x,y) translating function. Test it by centering black square on a tile (because in iso view it's always centered), and moving mouse over bottom canvas - a translated dot will be shown on izo canvas: – Markus von Broady Oct 2 '12 at 8:30
Thanks! I actually managed to deduce (well, sort of) something myself, namely the isometric offset in the drawIsometric function. Now it's looking like this:, which seems to do just what I asked in the original question, so I'll mark your answer. :) – xtr486 Oct 2 '12 at 23:14
I'm glad you did it! I like how WA, WD, AS, SD key kombinations align movement to isometric axes instead of 45 degree angles. Good work. – Markus von Broady Oct 3 '12 at 6:35

If I understand, you want the player move tile to tile but without jumping. You can:

1- Start with tile t0 and offset 0

2- When player move to tile t1 set offset = -(t1 - t0)

3- In the player update, if offset is not 0, decrement using the update time and player speed.

amount = deltatime * playerSpeed
deltaoff = sqrt(offsetX*offsetX + offsetY*offsetY)
total = min( amount, deltaoff )
offsetX = offsetX - (total * offsetX / deltaoff)
offsetY = offsetY - (total * offsetY / deltaoff)

4- Yo can use offset == 0 check to know when player is on tile.

With this you get a player that move free in the map but stick to the tiles.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.