Jump to content
  • Advertisement
Sign in to follow this  
suliman

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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! :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!