Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example #2

Open
GoogleCodeExporter opened this issue Jan 27, 2016 · 2 comments
Open

Example #2

GoogleCodeExporter opened this issue Jan 27, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Can you give an example on how to build the map array of locations and find a 
path.

ex: var map:array=[[0,0,0]]; 


thanks.


Original issue reported on code.google.com by ansar...@gmail.com on 7 Jul 2011 at 4:20

@GoogleCodeExporter
Copy link
Author

map is a Two Dimensional Array Containing Obstacle Map marked with 1 or 0 
values where 1 is obstacle:

Example

map:array = [[0,0,1], [0,0,1], [0,0,1]];

this is a 3x3 map containing a wall of obstacles on one side.

Original comment by avetis.z...@gmail.com on 13 Aug 2011 at 6:28

@GoogleCodeExporter
Copy link
Author

Here a more complete example:


var map:Array = [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 1, 0, 0, 0, 0, 0, 0]];

var pt:Pathfinder = new Pathfinder();           
pt.loadMap(map, 10, 10);
var path:Array = pt.getPath(new Point(1, 1), new Point(8, 8), false);   


var myShape:Shape = new Shape(); 
addChild(myShape);

myShape.graphics.lineStyle(2, 0x990000, 5);

for (var i:int=0; i<path.length; i++) {
    trace(path[i].x, path[i].y)
    myShape.graphics.lineTo(path[i].x, path[i].y);;
}

Original comment by fluoc...@gmail.com on 3 Mar 2012 at 6:53

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant