Public Group

# making around-the-globe gamemap? (strategy game)

This topic is 1099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi!

Im making a empire-builder and got stuck on how to make a round-the-globe kind of map. What i have now is a grid-based map with "hard borders". The map ends and units cannot travel past the borders (like starcraft, age of empires etc).

What i want is units travelling west from the Americas will end up in asia (like in the civilization games). So up/down on the map are still hard border, while left/right should be "connected".

I think i can solve the panning and drawing of terrain/units etc in the right places. But how about pathfinding and movement of units? Im using A* that ive gotten to work from the internet, but i dont fully understand everything of it. What would be the way to do it?

Thanks!
Erik

##### Share on other sites
Wrapping around is a matter of using modulo, or (unsigned) integer overflow in the easiest case. The issue with wrapping around (with quaternions too, by the way) is always that there are always two ways that lead to your goal. The "right" way, and the "wrong" way. But no matter which one you choose, you always eventually arrive where you want, if only you keep marching long enough. Now of course, you want the shortest possible way, not the longest possible. What's the solution? Simply run pathfinding twice, once towards the goal's coordinates, and once towards goal + map_width, and then choose whichever is shorter.

##### Share on other sites

Just add additional connections between (0, yPos) and (max_x_index, yPos) and thats it for the path finding.

##### Share on other sites

Yes, no need to run pathfinding twice.

The modulo solution will however not lead to a true spherical ("global") map, but rather a cylinder (if you wrap in one axis but no the other) or toroidal (if you wrap in both axes). This can be perfectly fine, and has been done in many games. Just a thing to keep in mind.

##### Share on other sites

The modulo solution will however not lead to a true spherical ("global") map, but rather a cylinder

Yes certainly, but that's exactly what the OP wanted: "travelling west from the Americas will end up in asia [...] up/down on the map are still hard border".

Just add additional connections between (0, yPos) and (max_x_index, yPos) and thats it for the path finding.

That one is actually a really nice solution. Obvious when you think about it, but gotta have the idea first! :)

Thanks guys!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634076
• Total Posts
3015353
×