Move Character in 2D Maze, use Mouse instead of Keyboard

Hi! Let say I have a 2D array tile map. If I want to use mouse click to point where my character will go intead of using Key event. Do I really need to implement some AI, like search for shortest path and avoid objects and walls, between the current position and the destination (Where I click).

Can someone tell me an idea how to do, is there other easier way? Thanks!

[383 byte] By [Katzuraa] at [2007-9-28 8:26:20]
# 1

> Hi! Let say I have a 2D array tile map. If I want to

> use mouse click to point where my character will go

> intead of using Key event. Do I really need to

> implement some AI, like search for shortest path and

> avoid objects and walls, between the current position

> and the destination (Where I click).

Well no you don't, but that would make your character go through the walls then.

> Can someone tell me an idea how to do, is there other

> easier way? Thanks!

Search for depth-first algorithm or breadth(sp?)-first algorithm.

They are fairly easy to implement.

Kayamana at 2007-7-9 20:16:55 > top of Java-index,Other Topics,Java Game Development...
# 2
Do a search on google for the A* path finding algorithm.
zparticlea at 2007-7-9 20:16:55 > top of Java-index,Other Topics,Java Game Development...
# 3
Thanks!I know some A* and Alpha-Beta pruning also.Do you have any working example or code?
Katzuraa at 2007-7-9 20:16:55 > top of Java-index,Other Topics,Java Game Development...
# 4
Unfortunately no I don't have example code. There has to be some out on the web somewhere. :)
zparticlea at 2007-7-9 20:16:55 > top of Java-index,Other Topics,Java Game Development...
# 5
http://www.markwatson.com/opencontent/aisearch/DepthFirstSearch.javawill download on click
Aikmana at 2007-7-9 20:16:55 > top of Java-index,Other Topics,Java Game Development...
# 6
I have written an A* shortest path algorithm specifically for a 2 dimensional grid (with every position empty or not empty)You can get it from http://allserv.rug.ac.be/~jpwinne/astar/
jpw35a at 2007-7-9 20:16:55 > top of Java-index,Other Topics,Java Game Development...