• 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 Minimap with "revealing" feature and clipping to viewport only when minimized

D

Dharmatrooper

Guest
Is there any tutorials on subject or good explanations?

So far i managed to create a minimap from the room. I have some issues like for some reason it does not follow my camera view and only shows top-left part of the room for some reason. (that's another question: how do you scan through objects that only visible in camera_view[0]?)

I want to show only impassable objects so i cycle trough all my "walls" tiles and draw sprites that represents them.

The question is how to kinda "reveal" minimap basing on radius around player object? I have no idea how to do it yet.
 
D

Dharmatrooper

Guest
obj_minimap

//CREATE
oSurface = -1;
//hide sprite
sprite_index = -1;

//STEP
if (!surface_exists(oSurface)){
oSurface = surface_create(camera_get_view_width(view_camera[0]), camera_get_view_height(view_camera[0]));
}

surface_set_target(oSurface);
draw_clear(c_black);
var numObjects = instance_number(obj_wall);
for ( var i = 0; i < numObjects; i++ ) {
var obj = instance_find( obj_wall, i );
with(obj){
draw_sprite( spr_minimap_wall, 0, x, y );
}
}
surface_reset_target();

//DRAW GUI
if (surface_exists(oSurface)) {
var h_scale = camera_get_view_height(view_camera[0])/2;
var w_scale = camera_get_view_width(view_camera[0])/2;
draw_surface_stretched( oSurface, 40, 40, w_scale, h_scale );
var old = draw_get_color();
draw_set_color(c_white);
draw_rectangle( 40, 40, w_scale + 40, h_scale + 40, true);
draw_set_color(old);
}
 
Top