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

Help with Radar/Minimap and drawing it to the screen.

B

bluGecko

Guest
Hi,

My current project is a top down shooter. I have an NPC object which I would like to have displayed on a Radar/Minimap. I would like the NPC object to be represented as a red square on said Radar/Minimap.

I have tried many different solutions that i have come across online. All of them do what I need, except for one big issue. They only work in the "Draw" event. Is there any way at all to have a Radar/Minimap drawn by using the "Draw GUI" event???

Thank you in advance

Here is an example of the code I was trying to use:
Code:
var d,a,radarX,radarY;

radarX = obj_player.x;

radarY = obj_player.y;


with(obj_npc)
{
    d = point_distance(radarX,radarY,x,y);

    if(d <= 600)  // This is the distance to check for

    {

        d = d/600*75;

        a = point_direction(radarX,radarY,x,y)

        draw_sprite(spr_radar_npc, 0, 75 + lengthdir_x(d,a), 600 + lengthdir_y(d,a));

    }

}
 
Last edited by a moderator:
J

JFitch

Guest
You should be able to do that in the Draw GUI event. What's an example of a code you've tried?
 

Simon Gust

Member
Since the positions in the GUI are added to view_xview and view_yview, you can just subtract them.

Code:
var d,a,radarX,radarY;

radarX = obj_player.x - view_xview;

radarY = obj_player.y - view_xview;



with(obj_npc)

{


   d = point_distance(radarX,radarY,x-view_xview,y-view_yview);

   if(d <= 600)  // This is the distance to check for

   {

       d = d/600*75;

       a = point_direction(radarX,radarY,x-view_xview,y-view_yview)

       draw_sprite(spr_radar_npc, 0, 75 + lengthdir_x(d,a), 600 + lengthdir_y(d,a));

   }

}
 
B

bluGecko

Guest
Since the positions in the GUI are added to view_xview and view_yview, you can just subtract them.

Code:
var d,a,radarX,radarY;

radarX = obj_player.x - view_xview;

radarY = obj_player.y - view_xview;



with(obj_npc)

{


   d = point_distance(radarX,radarY,x-view_xview,y-view_yview);

   if(d <= 600)  // This is the distance to check for

   {

       d = d/600*75;

       a = point_direction(radarX,radarY,x-view_xview,y-view_yview)

       draw_sprite(spr_radar_npc, 0, 75 + lengthdir_x(d,a), 600 + lengthdir_y(d,a));

   }

}
I tried this code in a "Draw GUI" event, It didn't seem to work. Is there anything else that needs to be done?
 

Simon Gust

Member
I'm just seeing it now, the second view_xview should be view_yview.
If you didn't already corrected it.

If it doesn't work, do it step by step.
Try drawing a simple sprite at 10, 10 and check if you see it.
 
B

bluGecko

Guest
I'm just seeing it now, the second view_xview should be view_yview.
If you didn't already corrected it.

If it doesn't work, do it step by step.
Try drawing a simple sprite at 10, 10 and check if you see it.
I changed the second view_xview to view_yview and sadly that didnt fix it. In my obj_hud, i have plenty of sprites being drawn using "Draw GUI" which all show up fine, so I am unsure what the issue is.
 
Top