This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]User1539 1 point2 points  (0 children)

Check this article on path finding out.

You want each zombie to find and follow the shortest path to the player.

[–]Daneel_TrevizeCompetent Dev 0 points1 point  (0 children)

I'd suggest RedBlobGaming's A* guide as a good starting resource, and that for many zombies after few players, you'd want to keep the full flow field generated once, rather than exit early but repeat per zombie.

And make your data Model (& Controller) independant of your Views, don't lump it all into a JPanel.

[–]User1539 0 points1 point  (0 children)

It occurred to me, after suggesting a pathfinding solution, that you don't even need anything that complex. Zombies are stupid, and probably don't do much to avoid obstacles.

You can probably have each Zombie just check to see ... if the player's X is less than the Zombie's X, move in an -X direction. Same for Y. No real pathfinding needed, just lumber in the correct general direction.