Map movement how to?

Hello, this is the map for my game, as you can see on the right i want to make 2 type of movements safe and fast. With the safe the player will follow the roads, with the other one will move in a straight line. Now my dubt is, how do i make it follow the road? Have to store all the routes? Or someone of you have some suggestion? Thanks

You have to store the road data in some format. An simple way would be a series of points and connections between the points (aka a graph).

1 Like

This is basic path finding stuff… if you’re new to this stuff you’ll find it very interesting… I did, anyway, the first time I had to learn about it.

Like @yaustar said you’ll no doubt end up storing your roads in a graph data structure. Then it’s a matter of writing a relatively simple algorithm to ‘walk’ the graph and find the shortest route from point A to point B. Here are some resources to help you learn about this stuff:

Thanks, i am already writing the code for the shortest route, my dubt was about the safest (following the road) and as i thought i have to save the road routes…just thought of a way to do it in the same json where i stored the data of the map :smiley: …smart ideas come always at night lol

Already made the shortest route…not easy with exagons :stuck_out_tongue:

1 Like

Accomplished also the safe route following roads :smiley: Now start the real task of building a world!