moving player with mouse

50 views
Skip to first unread message

Artur [Joker]

unread,
Feb 9, 2012, 12:45:58 AM2/9/12
to HTML5 Game Development
i just want to know how to move player with mouse click, but with
'blocks' in map, like the sims, the player 'chose the best way to get
there'.
how do to it in javascript + canvas [html5] ?

Szymon Piłkowski

unread,
Feb 14, 2012, 1:12:40 PM2/14/12
to html5-game-...@googlegroups.com
Hi,
You should read about A*: http://en.wikipedia.org/wiki/A*_search_algorithm
There are existing javascript implementations, but seriously, you'll learn a lot if you try to write your own. At least I did. :)

Szymon
--
Szymon Piłkowski :-: http://twitter.com/ard
"To, co nazywamy normalnością, to tylko krąg światła wokół ogniska"

Joshua Farrar

unread,
Jan 2, 2015, 3:07:56 AM1/2/15
to html5-game-...@googlegroups.com
I've recently been dissecting Browserquest (https://github.com/mozilla/BrowserQuest)

There are two functions you can take a look at, both in game.js


click() and getMouseGridPosition()

They have a pathfinding algorithm, but I haven't dissected that yet so you're on your own!
Reply all
Reply to author
Forward
0 new messages