Sign in to follow this  
JuliusDegutis

2D Pathfinding

Recommended Posts

JuliusDegutis    377

Hello, as allways doing some feature to my "game engine", and now I need info about path finding. Maybe anybody could give some advice what to read smile.png

What I want I painted, so would be easier to explain. There is pictures https://www.dropbox.com/sh/3apm1hupb12xdu4/jGuutop3aB

 

I need that my object go from one point to another.  As in first picture, if there is no blocks in path, so go simple straight line. Only begin and end points. As in second, if there would be block in path, find fastest way to walk around it. Now would be three point: begin, block corner and end points. If there would be more blocks - so more points would be too. 

My game is will be tile based. Now all object is 32x32 (tiles, enemies and so on), but what I thinking, is to make tiles 4x4, and all object would be same proportion as it (4x4, 8x8, 16x16, 32x32 ...) so one object could be on more then one tile. But it's just thinking for now

 

And sorry for english, really hard to remember to write good smile.png

Edited by Plutonium

Share this post


Link to post
Share on other sites

Can't see your picture...

 

You want to look at the A* algorithm for tile based (or node based) pathfinding http://en.wikipedia.org/wiki/A*_search_algorithm

 

which is usually more efficient than Djikstra's algorithm which is basically just a flood fill.

 

EDIT: I can see your picture now, can't see any tiles though ;)

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites
JuliusDegutis    377

Can't see your picture...

 

You want to look at the A* algorithm for tile based (or node based) pathfinding http://en.wikipedia.org/wiki/A*_search_algorithm

 

which is usually more efficient than Djikstra's algorithm which is basically just a flood fill.

 

EDIT: I can see your picture now, can't see any tiles though ;)

think that all rectangles are tiles (could be more then one in same place) and all other is alot of white rectangles :D that was just fast drawing :) 

But maybe not tiled based game would be better? Talking about pathfinding

Share this post


Link to post
Share on other sites

Well check out A* anyway... or try doing it with Dijkstra's algorithm first which is easier to understand.

 

A* and Dijkstra's algorithm depend on nodes (which would be tile midpoints in a tile based game) existing on the map. (If you don't have tiles you need to subdivide your space into regions and place a node in each one, like a waypoint system).

 

http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

Share this post


Link to post
Share on other sites
ultramailman    1720

But maybe not tiled based game would be better?

Your game map doesn't have to be tiled. If you can make a graph that represents your map, then you can use A* or Dijkstra's.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this