• 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!

GameMaker Mini Map Issues

Papa Doge

Member
I'm working on a top down shooter that includes a mini map. For my mini map I'm using the technique outline in this tutorial...


The tl;dr on the tutorial is that he takes a screenshot of the game room with all the dynamically positioned objects hidden, crops the result so it's the same aspect ratio as the room, then creates a static background sprite for the mini map and draws the dynamic pieces on top.

I have 5 different objects that I am drawing dynamically on top of this mini map and they are all showing up in the right places and displaying the appropriate logic to mirror the room environment.

However, I have a couple issues...

1) The sprite that I am using for the mini map is for some reason also showing up on my parallax "space" layer which is a transparency over a solid background.
2) No matter what color options I select for the function draw_sprite_ext() I see grayscale representations on my mini map.

I've added a screenshot to illustrate the problems I'm seeing. The mini map is in the top right and you can see it being drawn again through the hole in the floor on the bottom left.

Here is the code that I am using for the mini map based on the tutorial...

Code:
/* -------------------- */

// DRAW PLAYER

if (instance_exists(obj_player_bottom)) { // IF the player is still alive...
    // Set X and Y of the mini map player to match the scale of the mini map...
    player_x = obj_player_bottom.x*mini_map_percentage;
    player_y = obj_player_bottom.y*mini_map_percentage;
    draw_sprite_ext(spr_player_bottom,0,x+player_x,y+player_y,mini_map_percentage,mini_map_percentage,obj_player_bottom.image_angle,c_white,0.8); // Draw the player to the mini map
}

/* -------------------- */

// DRAW ENEMIES

if (instance_exists(obj_enemy_alive)) { // IF there are any living enemies in the room...
    with(obj_enemy_alive) { // WITH every instance of a living enemy...
        // Set the X and Y of this enemy to match the mini map's percentage...
        var enemy_x = x * other.mini_map_percentage;
        var enemy_y = y * other.mini_map_percentage;
        // Then draw a representation of the enemy using all the defaults for this living enemy...
        draw_sprite_ext(sprite_index,image_index,other.x+enemy_x,other.y+enemy_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_red,0.8);
    }
}

/* -------------------- */

// DRAW SENTRIES

if (instance_exists(obj_sentry_bottom)) { // IF there are any working sentries in the room...
    with(obj_sentry_bottom) { // WITH every instance of a working sentry...
        // Set the X and Y of this sentry to match the mini map's percentage...
        var sentry_x = x * other.mini_map_percentage;
        var sentry_y = y * other.mini_map_percentage;
        // Then draw a representation of the sentry using all the defaults for this working sentry...
        draw_sprite_ext(sprite_index,image_index,other.x+sentry_x,other.y+sentry_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_teal,0.8);
    }
}

/* -------------------- */

// DRAW CROPS

if (instance_exists(obj_crop_berries_alive)) { // IF there are any living crops in the room...
    with(obj_crop_berries_alive) { // WITH every instance of a living crop...
        // Set the X and Y of this crop to match the mini map's percentage...
        var sentry_x = x * other.mini_map_percentage;
        var sentry_y = y * other.mini_map_percentage;
        // Then draw a representation of the crop using all the defaults for this living crop...
        draw_sprite_ext(sprite_index,image_index,other.x+sentry_x,other.y+sentry_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_green,0.8);
    }
}

/* -------------------- */

// DRAW PORTALS

if (instance_exists(obj_portal)) { // IF there are any portals in this room...
    with(obj_portal) { // WITH every instance of am open portal...
        // Set the X and Y of this portal to match the mini map's percentage...
        var portal_x = x * other.mini_map_percentage;
        var portal_y = y * other.mini_map_percentage;
        // Then draw a representation of the portal using all the defaults for this open portal...
        draw_sprite_ext(sprite_index,image_index,other.x+portal_x,other.y+portal_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_red,0.8);
    }
}


/* -------------------- */

// DRAW MINI MAP

draw_sprite_ext(spr_mini_map,0,x,y,1,1,0,c_white,0.2); // Draw the mini map to the screen with some transparency...
 

Attachments

Papa Doge

Member
Looking at this with fresh eyes this morning I was able to fix issue #1 though in a way that doesn't really make sense to me. I am using the DRAW GUI event to draw the mini map and the scaled sprites. Then I use a separate DRAW event that is blank. This blank DRAW event is removing the duplicate I am seeing of the mini map.

Why I'm not sure. All I can think is that without saying draw_self() in the DRAW event for the mini map I'm telling the mini map not to draw itself and then I use draw_sprite_ext() in the DRAW GUI event to create the scaled version I want.

Still no luck on #2. I tried drawing the sprites in different orders, changing the colors, etc. I end up with one of the object types colored and it almost looks like my code is recoloring the same object over and over in layers or something. Quite strange and not sure what else to try. I added an updated screenshot.
 

Attachments

Papa Doge

Member
Never was able to figure out what was wrong with my use of draw_sprite_ext() but I actually something that works just as well in draw_circle_color(). With the mini map that small you can't make out details in the scaled down sprites anyways!

Here's the code I'm sticking with for now...

Code:
/// @description

/* -------------------- */

// DRAW MINI MAP

draw_sprite_ext(spr_mini_map,0,x,y,1,1,0,c_white,1); // Draw the mini map to the screen with some transparency...

/* -------------------- */

// DRAW PLAYER

if (instance_exists(obj_player_bottom)) { // IF the player is still alive...
    // Set X and Y of the mini map player to match the scale of the mini map...
    player_x = obj_player_bottom.x*mini_map_percentage;
    player_y = obj_player_bottom.y*mini_map_percentage;
    draw_circle_color(x+player_x,y+player_y,2,c_white,c_white,false);
    //draw_sprite_ext(spr_player_bottom,0,x+player_x,y+player_y,mini_map_percentage,mini_map_percentage,obj_player_bottom.image_angle,c_teal,1); // Draw the player to the mini map
}

/* -------------------- */

// DRAW ENEMIES

if (instance_exists(obj_enemy_alive)) { // IF there are any living enemies in the room...
    with(obj_enemy_alive) { // WITH every instance of a living enemy...
        // Set the X and Y of this enemy to match the mini map's percentage...
        var enemy_x = x * other.mini_map_percentage;
        var enemy_y = y * other.mini_map_percentage;
        draw_circle_color(other.x+enemy_x,other.y+enemy_y,2,c_red,c_red,false);
        //draw_sprite_ext(sprite_index,image_index,other.x+enemy_x,other.y+enemy_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_red,1);
    }
}

/* -------------------- */

// DRAW SENTRIES

if (instance_exists(obj_sentry_bottom)) { // IF there are any working sentries in the room...
    with(obj_sentry_bottom) { // WITH every instance of a working sentry...
        // Set the X and Y of this sentry to match the mini map's percentage...
        var sentry_x = x * other.mini_map_percentage;
        var sentry_y = y * other.mini_map_percentage;
        draw_circle_color(other.x+sentry_x,other.y+sentry_y,2,c_white,c_white,false);
        //draw_sprite_ext(sprite_index,image_index,other.x+sentry_x,other.y+sentry_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_green,1);
    }
}

/* -------------------- */

// DRAW CROPS

if (instance_exists(obj_crop_berries_alive)) { // IF there are any living crops in the room...
    with(obj_crop_berries_alive) { // WITH every instance of a living crop...
        // Set the X and Y of this crop to match the mini map's percentage...
        var crop_x = x * other.mini_map_percentage;
        var crop_y = y * other.mini_map_percentage;
        draw_circle_color(other.x+crop_x,other.y+crop_y,2,c_white,c_white,false);
        //draw_sprite_ext(sprite_index,image_index,other.x+crop_x,other.y+crop_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_yellow,1);
    }
}

/* -------------------- */

// DRAW PORTALS

if (instance_exists(obj_portal)) { // IF there are any portals in this room...
    with(obj_portal) { // WITH every instance of am open portal...
        // Set the X and Y of this portal to match the mini map's percentage...
        var portal_x = x * other.mini_map_percentage;
        var portal_y = y * other.mini_map_percentage;
        draw_circle_color(other.x+portal_x,other.y+portal_y,2,c_red,c_red,false);
        //draw_sprite_ext(sprite_index,image_index,other.x+portal_x,other.y+portal_y,other.mini_map_percentage,other.mini_map_percentage,image_angle,c_blue,1);
    }
}
I left the old stuff in there commented out in case I ever want to come back to this, but I think drawing circles works just fine for my proof of concept. I'll leave this as unsolved in case anyone stumbles in and knows how I was using draw_sprite_ext() incorrectly.
 
Top