XNA pathfinding

Started by
2 comments, last by Darg 14 years, 3 months ago
Hi I'm trying to create a 2D Tower Defense game with XNA. Sofar I've done a tilemap with a path on it. The map is done with a multidimensional array and the path is a hardcoded 2d-array with coordinates. I've got an enemy to follow the path correctly, but I think I'm going down a silly path.. Is this a good way of implementing this - or is there a better way? The pathfinding will eventually be done with a A* implementation, but how would I do that on a multidim. array? - Would it be better to create a map based on a collection of tile objects a la List<Tile>? It just seems like a "heavier" solution, but might be more "flexible". Be gentle... I'm new to gamemaking :P
New to XNA
Advertisement
Your approach is more than adequate. It might be worth it to keep a list indexing into your tilemap which could be more easily iterated through but if what you have is working then don't worry about it unless you have to. A* is about dynamic pathfinding and you have no need of such.
[size=2]
The reason I'll probably implement a A* is because I'm going to create a level editor eventually and to have some weapon be able to manipulate the maps (collateral damage = destroy stones).. and I'd like the enemies to use this to find a better route.. I.e. a "smart" tower defense game :P
New to XNA
I've always preferred to use straightforward position arrays instead of an object for each map node when using A*. It's a personal choice though, I tried it both ways, the array method just seemed to be a simpler solution to me.
Portfolio & Blog:http://scgamedev.tumblr.com/

This topic is closed to new replies.

Advertisement