Simon Donkers
Game Maker
Home > GameMaker > Scripts > Circulair radar script

Circulair radar script

This script will generate a GTA like circulair radar. It will show all objects within a given radius with the objects sprite scaled. There are some problems when using large sprites since they can stick out of the radar a bit.

 Circulair radar script
//////////////// Circulair radar script ////////////////////
// Copyright Simon Donkers 27-1-2005
// -
// the arguments are: behind is recommandable value
// argument0 is radius
// argument1 is controller object
// argument2 is fixing point x
// argument3 is fixing point y
// argument4 is radius of what is visible.
// This script will create a circulair radar at the
// left bottom corner of the screen with the given radius
// In this circle all objects within distance argument4 to
// the fixing point will be drawn by there sprite but scaled
// argument1 or objects whose parent this object is
// will not be drawn
global.center_x:=view_left[0]+view_width[0]-10-argument0//x coordinate of circle
global.center_y:=view_top[0]+view_height[0]-10-argument0//y coordinate of circle
brush_color:=c_yellow//The background color of the radar.
with all
        //if it isn't a controller and it is within distance
        if object_index!=argument1 and point_distance(argument2,argument3,x,y)<argument4then
                draw_sprite_ext(sprite_index, -1,global.center_x+(x-argument2)/argument4*argument0global.center_y+(y-argument3)/argument4*argument0argument0/argument4,argument0/argument4,1);
pen_color:=c_black//border color of the radar
pen_size:=4; //border width of the radar. (Some objects might be visible whose origin is within the circle but of which the rest of the body isn't. This border will be drawn over them