Skip to main content
gamedev.net
🔒 Locked

Map Interface

Started by silverRohan Jan 27, 2004 at 9:46 PM 1 replies 850+ views
Original Post
silverRohan
silverRohan
Okay, quite simply, I have been working on a program that takes 2D maps like a rectangular map of the Earth, some data on borders, etc. to produce an environment where the user can select the countries/cities/etc. on them. This is all kinda up in the air still since most of the idea is in the design phase. I''ve been thinking that to simplify processing and figuring out where the user has clicked I might want to use quadtrees. Still, not sure if that is a good idea. So really, this post is to ask if anyone has a better idea. Do you?
SelethD
SelethD
This might not be the most elegant idea, but its probably the simplest to do, and the fastest to process.

have two surfaces
s1 surface with map
s2 surface of map with each country filled in with a color

have both surfaces loaded in memory, display the s1 so they can see the map

have the mouse read the pixel color on s2 and the mouse x,y

then by what color is read from s2, have a lookup table that tells what country city or whatever

Example using RGB R & G for country B for city
paint on s2, USA 000100 and say new yorkcity 000101
paint on s2, canada 000200 and whatever canadian cities start at 000201 so you have a max of FFFF (256*256) (i dont have a calc on me) different countries, and each country can have FF (256) cities.

Ok thats my idea
Cornutopia
Cornutopia
I used that color map system for my game Radioactive. It works but can be memory intensive depending on how much accuracy/resolution you need for your map.

For a massive map you might be best going for some polygon in/out tests where each country is a polygon.

You could cross the two. Have a second color coded map made from unlit polygons and render a small area on a hidden surface, then check that.

Mark
Flatspace is here: The ultimate space adventure
http://www.lostinflatspace.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.