• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Minimap Problem

Imperial

Member
Hello

I'm trying to make a minimap that redraws Everything but In Specific zone

this is what I have so far

Code:
var minimap_x = argument0;
var minimap_y = argument1;

var minimap_xscale = sprite_get_width(spr_MiniMap_Background)/room_width;
var minimap_yscale = sprite_get_height(spr_MiniMap_Background)/room_height;

var scale = 5;
var playerX = 0;
var playerY = 0;

draw_sprite(spr_MiniMap_Background,0,minimap_x,minimap_y);

if(instance_exists(Player))
{
    playerX = Player.x * minimap_xscale;
    playerY = Player.y * minimap_yscale;
    draw_sprite_ext(spr_player,0,minimap_x + playerX,minimap_y + playerY,minimap_xscale * scale,minimap_yscale * scale,Player.image_angle,-1,1);
}

for(i = 0; i < instance_number(Enemy); i++)
{
    var current = instance_find(Enemy,i);
    xx = current.x * minimap_xscale;
    yy = current.y * minimap_yscale;
    draw_sprite_ext(spr_enemy,0,minimap_x + xx,minimap_y + yy,minimap_xscale * scale,minimap_yscale * scale,current.image_angle,-1,1);
}

for(i = 0; i < instance_number(Tree); i++)
{
    var current = instance_find(Tree,i);
    xx = current.x * minimap_xscale;
    yy = current.y * minimap_yscale;
    draw_sprite_ext(spr_tree,0,minimap_x + xx,minimap_y + yy,minimap_xscale * scale * 0.25,minimap_yscale * scale * 0.25,current.image_angle,-1,1);
}
the problem with this minimap is It's just re-draws everything in the map not just a small portion

can you please show me how to make It to re-draw just a small portion of the map ?

Just a small zone where the player is standing
 

Alexx

Member
Just check the distance from player to the target object. Only draw if below a certain distance.
This makes a circular mini map
 
Are you trying to draw everything that would normally be visible in the normal view? Or do you want to draw a kind of iconic representation of obstacles or enemies or other things?
 

Imperial

Member
Are you trying to draw everything that would normally be visible in the normal view? Or do you want to draw a kind of iconic representation of obstacles or enemies or other things?
It doesn't matter I just want to re-draw the map in surface as a minimap

not the Entire map just a small portion of It, the zone where the player is standing
 

TsukaYuriko

☄️
Forum Staff
Moderator
To make sure we're talking about the same thing: Are you trying to limit what gets drawn to the minimap to just the things which are located close to the player? I'd assume the reason for this would be some sort of optimization? That's what I understood from your problem description - the solution I can suggest depends on whether I understood it correctly.
 
Yes the same as the main view
I think an easy solution to your problem would be to use a second view, and use view_surface_id to assign a custom surface to that view. That will stop gamemaker from drawing the view surface automatically (unfortunately the manual only implies this rather than stating it explicitly), which allows you to draw the view surface when, where, and how you please.
 
Last edited:

Imperial

Member
To make sure we're talking about the same thing: Are you trying to limit what gets drawn to the minimap to just the things which are located close to the player? I'd assume the reason for this would be some sort of optimization? That's what I understood from your problem description - the solution I can suggest depends on whether I understood it correctly.
Yes thats correct
 

Joe Ellis

Member
Yeah just create a new view and a new surface, the center of the view is the player's position, and the width & height of the view is controlled by a certain radius, simple.
Also you won't need to use the minimap scale if the view and surface are controlled right, they'll just get scaled properly
 
Top