Coloring Odd Shaped Areas

Started by
3 comments, last by Dovyman 21 years, 4 months ago
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-
Advertisement
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]
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"
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Hey thats a neat idea! thx guys. I''m still looking for any ideas on how to be able to recolor specific regions on the map.
Any suggestions?

-Paul-
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"
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials

This topic is closed to new replies.

Advertisement