Advertisement

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

Started by January 15, 2016 09:10 AM
2 comments, last by suliman 8 years, 11 months ago

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

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.
Advertisement

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

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.

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!

This topic is closed to new replies.

Advertisement