Path finding class

magic

Active Member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
I download and test it. Thanks a lot for another module.

The module and sample look good but I don't really understand how to implement in my game.
 

Rich

Active Member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Sep 9, 2017
Adding this to any game, may be a bit of an exageration. Obv it requires a maze like game.
Platformers or open worlds might be a bit difficult.

Im assuming you would have you maze data in a 1D array with a width and height.
All walls would have a value of 1 and path would be 0

your enemy would be at x,y in that map (its posiiton in the array would be enemy_position = enemy_x+enemy_y*width)
your posiiton would also have an x,y (so your psoition in the array would be player_position = you_x + you_y*width)

If you call p.GetRoute( enemy_position, player_position, map, width, height, 0), this would find a path from the enemy to the player.
p.Route might look lie [0,1,2,8,9,15,16] if theres a path or [] if there isnt

How you traverse that array and move your characters really depends on your game.

if i was to create inteligent enemys, i would call p.GetRoute more than less inteligent ones (say once every second rather than every 3 seconds)

I may add another example showing a simple enemy v player later
 

Rich

Active Member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Sep 9, 2017
That's more impressive than my example ;-)
Thanks for the offer, I'll pop a header in the code with your username and link to this thread and add it to the module examples.
Thank you
 
Top Bottom