Jump to content
  • Advertisement
Sign in to follow this  
suliman

Movement on risk-like map (regions, not tiles)

Recommended Posts

Posted (edited)

Hi!

Turnbased strategy game: Any good idea on how to implement a risk-like map where armies are moved between regions/sectors on the map instead of on a tilebased map?

My idea is to set each connection manually in the map editor: select a region and then mark each other region it is connected to. When later moving an army these connected regions are the only valid moves. Makes sense? Any way to automate this process?

blank-risk-png.30809

Edited by suliman

Share this post


Link to post
Share on other sites
Advertisement

You'd need to have the regions themselves first, don't quite see how to automate that, perhaps semi-automatic flood-fill of an area until you hit yellow or dark colour. From there, you can probably look for neighbouring pixels that belong to another region.

Not sure it's worth the time, doing it manually isn't that complicated, and you don't even need the regions precisely in that case. (Although it may be nice for a player to easily select a region by clicking it on any spot.)

Share this post


Link to post
Share on other sites

You could use a node based system.

Define each region as one node with x and y coordinates and then link them (e.g. in another array).

If you want you could also make one directional routes that only go in one direction (e.g. you can go from China to India but not back), which would make the linking a bit easier but less logical.

 

for example:

var regionA = {id=>'A', x=>100,y=>200};

var regionB = {id=>'B', x=>10, y=>400};

...

var connections = {};

connections[] = {'A','B'};

 

If you want to have something more detailed you will have to do a much more complex approach which I wouldn't recommend if it is not really necessary.

Share this post


Link to post
Share on other sites
On 6/5/2018 at 1:55 AM, suliman said:

Any way to automate this process?

Just to be clear, what is being automated?

The game at its core is a connectivity graph. You pointed that out in your own post. 

Since this isn't in For Beginners, we assume you know how to manipulate a graph. Manipulating that type of graph is fundamental in computer science, they are included in the earliest data structures and algorithms courses. Often in the first year of studies they start with trees then include more connected meshes.

 

The other part, creating a connectivity graph out of an image, is not something that can be easily automated. Identifying areas of uniform color is straightforward enough, but anything more than that requires either a human or an enormous amount of computing work. For example, how would you know the British Isles are a single unit, or Indonesia is a single unit? And heaven help the machine that must figure out the mess of northeastern Canada and Greenland.

Don't automate that part. Drop it in an image editor like Gimp or Photoshop, draw boxes around each zone, color each box with an indexed color of 1, 2, 3, 4, etc., and use those to build your clickable regions. When the user clicks on a point, run the coordinate through your indexed image, get the number, and use that to know which node the user picked.  (You can use more complicated regions, but there is no need.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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!