# How to make the minimap inactive?

I have created a minimap for my top-down Shooter and it is showed on the top-left corner of the window. The problem is that if I press anywhere upon the minimap, its like pressing somewhere on the normal game as I have used views to make it. Is there any way to make the minimap inactive?

It sounds like what you are doing for the minimap is another camera/viewport that is placed in the top-left corner of the screen. What should be done instead is a visualization of a portion of the area you are currently in.

For example, in a tile based game you can use the location of the player and choose a size for the minimap. What you do is then draw the minimap based on a box centered around the player and the tile data.

X = wall; E = enemy; @ = character; -| = camera bounds
SCREEN           MINIMAP
XXXXXXXXXXXXX    XXXXXXXXXXXXX
X   EX      X    X   X       X
X   |X----| X    X   X       X
X   |X @--| X -> X   X @     X
X   |-----| X    X           X
XXXXXXXXXXXXX    XXXXXXXXXXXXX


In the example above, the character is centered in a 5x3 bounding box used to generate the minimap. You can scan the tiles in the box and draw the minimap based on what is located there. With this method, the minimap is treated as a GUI object rather than another 'screen' for the game input.

Check your mouse XY is outside of the minimap space. Something like

if (mouse_x > minimapWidth && mouse_y > minimapHeight)
{
// OUTSIDE MINIMAP: do input stuff using mouseXY
}
else
{
// INSIDE MINIMAP: do minimap stuff using mouseXY
}


I had a problem like this myself, but don't remember exactly if you have to subtract the minimap values from the view's width and height too (I'm pretty sure top left is 0,0 when it comes to game maker's views, but do remember plenty of GUI stuff I did requiring subtraction of the view's width and height... then again my minimap was top right).

Logging mouse_x and mouse_y in the debugger and watching what numbers come up as you scroll about the view will give you the numbers you need regardless, and is a helpful practice for doing GUI stuff.

• Thanks, for the reply. I tried that, but now it is applied on both views. What i mean is that now i am able to press half of the normal view and half of the minimap :/ as the minimap is a copy of the normal view. – Panagiotis Iatrou May 18 '16 at 12:42

If referring to the width/height of the mini map isn't working, you could try hard-coding in the parameters.

Or (silly idea), you could create a blank, transparent object the size of the mini map and check that the mouse isn't touching that?

Not a very efficient solution, but might get the job done for now.

• I had tried to put a transparent obj on the minimap, but now it is "applied" also in the normal view. What do you mean by saying hard coding in the parameters? – Panagiotis Iatrou May 27 '16 at 11:57
• You have the view containing the mini map overlaying the main view, correct? Since you know the dimensions of the map view, and it's origin, you can just tell objects in the main view to ignore mouse coordinates that fall into the mini map. I could be misunderstanding the scenario though, haha. – Abrexas May 29 '16 at 23:05

A view is a part of your room, you can't have 2 different behaviors in each one of them. One partial solution is to check if the X and Y are inside the main viewport, so in case the player clicks far away where the main viewport can't "see", it won't execute your code.

You can make this by checking:

//Assuming the main viewport is 0
if((x >= view_xview[0] && x <= view_wview[0]) && (y >= view_yview[0] && y <= view_hview[0]))
{
//Do stuff because I'm on a clickable area of the main viewport
}