Radar or Mini-Map in real-time, how is this done?

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
Verahta
Posts: 441
Joined: Wed Aug 24, 2011 1:50 am

Radar or Mini-Map in real-time, how is this done?

Post by Verahta »

You would think this would be a popular tutorial subject, but I am having one hell of a time finding anything at all. I asked the instructor of a basic level game course I took but I didn't want to pester him further, so I bring the question to you lot :twisted:

How do people code the mini-map radar's you see in games? (I'm thinking in the context of a PBBG/MMO built on a HTML5/JS/Node stack). Here is a visual example of the general idea I want to achieve:
Image


This is the reply I got which I mentioned previously, but I was hoping for answer a little bit more detailed:
The feature you're referring to is generally called a minimap or radar, depending on the game, but to draw one the main trick to it is that you just need to divide all object positions by a big number (the bigger the number, the closer together things will bunch on radar), and draw a colored circle or whatnot at that position instead of the graphic. There's no need to actually track or detect positions since the computer knows the actual coordinate positions of all things at all times. Since this feature is outside the scope of my course here I can't provide much more detail or troubleshooting on it here, but hopefully that's enough to get started on. Good luck with getting the feature sorted out!
What are the best methods for coding a real-time radar which displays nearby players and objects in the game popping up on it as they come in range or what have you? I could probably hack together something hideous and terribly inefficient, but I was hoping to learn a smart/efficient way of achieving this type of feature.
"In order to understand recursion, one must first understand recursion".
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Radar or Mini-Map in real-time, how is this done?

Post by hallsofvallhalla »

For instance if your map is 600px X 600px and your ship is 30px X30px and your mini map is 50px then you divide all cordinates on thw map by 600/50 which equals 12. So 30 /12 is your colored dot representations size. If your ship moves 12px per second then now it is 1px on the minimap.
Post Reply

Return to “General Development”