How can I imitate interaction and movement in Diablo II?

Posted by user422318 on Game Development See other posts from Game Development or by user422318
Published on 2012-03-28T05:00:39Z Indexed on 2012/03/28 5:43 UTC
Read the original article Hit count: 235

Filed under:
|

I'm prototyping a simple browser-based game. It's played from a top down perspective on a 2d canvas.

You left-click on a point on the map, and your character will begin walking to it. If you click on a different point on the map, then your character will begin walking to the new point.

It's similar to Diablo II: http://www.youtube.com/watch?v=EvDKt-To6K0&feature=related

How can I best imitate this movement system for a player? Ideas...

  • Track current coords and target coords

  • If target coords are exactly up, left, right, or down, then increment appropriate direction until you get there

  • Implied else: target coords are in a quadrant. To make this movement look natural, character will have to move diagonally. For example, pretend the target is to the northeast. For each game frame, alternate incrementing current coordinates in the north and then east directions.

© Game Development or respective owner

Related posts about JavaScript

Related posts about html5