Most effective way to create a Mini Map


(Adam Edney) #1

Hi Guys and Girls,

What would be the most efficient (use the least performance) to create a minimap. This map needs 3 components.

  1. Background image (this will not change, but not super important)
  2. When the player builds a building it will display that building (or a outline / white box)
  3. Track every enemy

The minimap will be zoomed out ALOT so an enemy may only a couple of pixels in size. I want the map to update depending on what upgrades the user has (once every 5 secs).

Would my best bet be a bitmap image?

Any ideas?

Thanks.


(rostok) #2

I would create another entity class for the mini map and would override render function. There one can iterate over all objects and manually paint them directly on screen after super.render(); with net.flashpunk.utils.Draw functions. Note that in original FP there’s no setPixel() method yet it is trivial to add (https://github.com/rostok/FlashPunk/blob/master/net/flashpunk/utils/Draw.as#L394).

I would paint it directly on screen but if this takes too much time you can create separate bitmap and draw on it in overriden update function for example every 2nd or 3rd frame.


(Zachary Lewis) #3

You could also override the render() function on any Entity that should be drawn on the minimap. That way, your enemies or buildings could draw themselves onto the minimap instead of having your minimap go find them and draw them.

You could go one step further and have some of those inherit from a parent class (like MinimapDrawableEntity) or implement an interface (IMinimapDrawable). This would allow you to easily add entities to your project that can be drawn on the minimap while preventing ALL entities from drawing on the minimap.