Archived

This topic is now archived and is closed to further replies.

Coloring Odd Shaped Areas

This topic is 5502 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

Im in the design phase of a Risk-type game. I was thinking about it and I came across a problem. How do I make the world map actually "interactive", what I mean by that is simply that each region on the map can be recolored, and knows when it has been clicked. Anybody have any ideas on how to implement something like this?? Any comments/ideas would be greatly appreciated! -Paul-

Share this post


Link to post
Share on other sites
If you made each area a different colour you could run a function to get the colour that is under the mouse at the time. Also if you are planning in not doing this in 2D you should take a look at the DX Pick Example it is exactly what you want.

[edited by - HunterTKilla on November 18, 2002 12:32:31 AM]

Share this post


Link to post
Share on other sites
Similar to the above post, but faster...

Instead of getting the actual screen color, encode a second bitmap with a single byte per pixel with values designating each region (up to 256). Load those "IDs" into a 2D array. With each click/move:

CurrentRegionID = Regions[x][y];

In some ways, the same as getting the screen color, but without locking, transfer issues, etc. Also, the "ID map" could be lower res than your real map, depending on how accurate you want to be.

Extra credit: compress the IDmap with a lossless compression (RLE, LZW, etc.) and write an algorithm that intelligently extracts the correct ID. Less memory, but slower.



Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"

Share this post


Link to post
Share on other sites
You could draw each country as an individual sprite, using alpha to mask off the shape. Once you get that in place, you can easily change the colors with changes to the texturefactor and the correct stage states. Think of the texture as a mask and the texture factor as the actual color. Alternately, you could apply two textures - a 1x1 texture for color and a larger texture for masking.

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"

Share this post


Link to post
Share on other sites