Minimaps!

4.5
Your rating: None Average: 4.5 (2 votes)
Difficulty Level: 
Intermediate
Topic: 
Game Coding

Looks like its time for another tutorial. I know that someone else already did a tutorial for a minimap, but I'd like to share with you how I do it Smiling

All types of minimaps:
Minimap Examples

Widget:
Minimap Widget

Quoted from my article Clickteam's Articles section:
"Part One

The Problem
DanielRehn's Minimap Extension is in beta and has an annoying pop up making it unusable if you want your game to be perfect.

The Solution

Make your own MiniMap!

Note: I do not yet have an example ready, will do as soon as I finish some projects

Making a MiniMap is incredibly easy. All you need is to be able to interpret what I say ( my social skills are limited - I am a nerd you know smile ) This article/tutorial will for sure help you figure out how to make a Minimap

HOW!?

First: Making a Minimap that displays entire frame

Start by making a simple active and make it into a box. Use the same ratio of the frame height to the frame width for the size and remember the scale. I'll call mine "Minimap bg". This will be the background for the Minimap.

Create another active. This will be an indicator to show where an object is on the minimap. Make its picture relatively small to the Minimap bg. Definitely smaller than the Minimap bg! It might be smart to keep it to scale of the actual object. Make as many of these as you like, all unique to their own object (clones not duplicates!) x) !

Note: To make backdrops on your minimap, you'll have to use a looping method... get more into that in another article/tutorial

***If you want to use qualifiers in your Minimap, do the following in the event editor. Otherwise, if you want to save space in your event editor, do the following in one of the Minimap bg's behaviors.***

Now to program! Start with an Always event:

*Always
-Set X position of "Indicator" to X("Minimap bg") + X("Object being indicated")/Scale Factor

where Scale Factor is the frame length or width divided by the Minimap bg's length or width respectively (just put the value not the expression smile ). And Object being indicated hopefully is self-explanatory smile .

This will show only one of the object's positions. So how do you make it show all of them?

test:

*NObjects("Indicator") < NObjects("Object being indicated")
-Create "Indicator"

This will create more instances at runtime if more objects are created. Now test:

*NObjects("Indicator") > NObjects("Object being indicated")
+Pick "Indicator"
-Destroy "Indicator"

This will destroy instances at runtime if the objects are deleted.

There's the simple one, now some special things you can do with it -

If you would like, you can set the Minimap bg to Semi-Transparent so that you can see things behind it. Experiment with light and dark and make it yours!

For convenience of the players that play your game, you should make your indicators small and Semi-Transparent so the players can see if something is underneath something.

Now for something really cool - Showing objects only if they are within a certain distance of the player. The next part will deal more with this in a different way, but for now, change the Always to Compare two General Values:

*Sqr(Exp(2)*(X("Player")-X("Object being indicated"))+Exp(2)*(X("Player")-X("Object being indicated"))) < Preferred Distance, eg. 600

This is simply the Distance Formula, but can also be achieved by the Advanced Direction Object if you find that too hard or if I did it wrong and it messes you up smile Just select "Distance between two points" in the Retrieve From Object's Advanced Direction Object dropdown. I personally do not use the extra extension and just using the formula to save the need of an extra object. Oh and you might want to add:

*Sqr(Exp(2)*(X("Player")-X("Object being indicated"))+Exp(2)*(X("Player")-X("Object being indicated"))) > Preferred Distance, eg. 600
-Make "Indicator" invisible

so that the indicator disappears when it is no longer within range Smiling

Coming back to edit and append... no worries!
By the way... this may or may not work - just from memory whistle and wrote in 30 minutes - so don't get totally t'oed at me, k? I'll fix it if I need to or I'll ask for permission to edit since the edit button disappears after a day or so."

Please tell me what needs fixing...

That's all for now but I may rewrite some other stuff

Comments

StephenL's picture
4

Nice article.

blade2000's picture

booooooooooooooooooooooooooooooooooooooooooooooooo

RickyRombo's picture

Explanation please?

I'd like to know what you didn't like so I can make it better Smiling