My game's map format uses a bunch of triangles to make up the platforms and terrain in 2d. Right now I can set up a 2d array of nodes for the astar algorithm that basically is a bunch of rectangles across the maps x and y that can be set to "wall" if the a* algorithm should try to go around it. However I want a function in the map loader to create the node overlay if the nodes are not specified. I was thinking if more than n percent of the a* rectangle overlaid on map was filled by polygons I could mark that entry in the array as "wall". However I'm stuck on how to do this(or even start) where/when the triangles can be overlapping and also of variable size.
You're starting with an image, and trying to overlay pathfinding information onto that. Generally this would be approached in one of the following ways
You can try to do it procedurally, it's going to be substantially more difficult though. If you are adamant about going down this route, obviously your approach has to be based on pixel colours, and so you may need to generate a secondary image that is used purely for A* pathing determination. |
|||||
|