Simon Donkers's Game Maker site siteSimon Donkers's Game Maker site
This resource is created for Game Maker 5 and isn't compatible with the latest version of Game Maker.
My apologies for the inconvinience.
Version: GM 5 Views: 11805 Script, Game Maker 5 compatible
Filesize: 1905 byte Creative Commons License

Circulair radar script

1/52/53/54/55/5 (12 votes)

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
// www.simondonkers.com - gmmentor@simondonkers.com
//
// 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
pen_size:=1;
brush_style:=bs_solid;
brush_color:=c_yellow; //The background color of the radar.
draw_circle(global.center_x,global.center_y,argument0);
with all
{
        //if it isn't a controller and it is within distance
        if object_index!=argument1 and point_distance(argument2,argument3,x,y)<argument4 then
        {
                draw_sprite_ext(sprite_index, -1,global.center_x+(x-argument2)/argument4*argument0, global.center_y+(y-argument3)/argument4*argument0, argument0/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
brush_style:=bs_hollow;
draw_circle(global.center_x,global.center_y,argument0);

Tip: Have a look at the tutorial How to execute a script

User comments

 TheMaN posted at 2005-02-19 00:35:29Quote
what are all the arguments

SD: I seem to have missed those when copying it from my old site. Thanks for pointing this out. They have been added now
 daniel posted at 2005-03-09 18:03:29Quote
Do i need a sprite??

SD: This script will draw the sprites of the objects within teh room scaled. So all objects that need to be shown need to have a sprite. Also this is only available for GM5
 No_SkillZ posted at 2005-04-02 03:37:42Quote
sorry to bother again, but can you tell me which part of the script I can change to make it GM6 compatibe, or do I have to write it all over again?

SD: This script is heavely based upon drawing the radar. And as all the drawing code has changed several parts need to be tweaked. There is a tutorial for converting GM5 to GM6 available here written by EricDB/Mr.Owl.
If you can't figure this out then contact me in 2 weeks time when my school tests are over and I'll have a look.
 CHK posted at 2005-05-21 11:43:50Quote
anyone have an example on this?
i cantget it right

SD: download.simondonkers.com/?file=temp/radar.zip
 -={SaLmIaK}=- posted at 2005-06-09 10:20:47Quote
Nice, Can I put this in my GM-Lib?
(You know those lib files in the folder lib)

SD: Hello,
If you would read my Licence agreement you would see that this depends on what you do with the lib. If you create this lib for your own personal use then yes. If you are planning to distribute this lib then you need to ask my permission. Please specify how you would like to distribute this lib, in what way credit is given, under what licence the lib is being released and which resources you are aiming to include. Contact details can be found on my contact page somewhere.
 Brenden posted at 2005-12-03 06:21:12Quote
I keep getting an error: Number of Arguments..blah blah blah..line 26!
 Simon Donkers posted at 2005-12-03 11:37:34Quote
This is a GM5 script. It will error in GM6. Sorry.
 Alegria posted at 2006-06-26 23:33:17Quote
What does it mean when you use :=
I don't know.
 Simon Donkers posted at 2006-06-27 09:45:38Quote
:= means the same as =. Both are notations used in Game Maker to assign a value to a variable.
 finney posted at 2006-08-16 21:30:21Quote
i cant see how it works, could you send me a example plz cos da 1 above dnt wokr nemore (link) and maybe send to my email address cos i dnt cum on here much..

thanks

email: finney2k6@hotmail.co.uk
 kizacolo posted at 2006-08-27 02:42:26Quote
umm simon that download for the example does not work. can you put it again please? also could you send the exact spript to make my character jump please? in a platform game? if you can send it to kizacolo@yahoo.com.au thanks
 boi posted at 2006-12-25 22:17:01Quote
yo yo yo iim gm rocky D and wazzaaaaaa
 PAG07 posted at 2007-04-21 22:32:03Quote
I modified it so it would work with GM6:

//////////////// Circulair radar script ////////////////////
//
// Copyright Simon Donkers 27-1-2005
// www.simondonkers.com - gmmentor@simondonkers.com
//
// 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_xview[0]+view_wview[0]-10-argument0; //x coordinate of circle
global.center_y:=view_yview[0]+view_hview[0]-10-argument0; //y coordinate of circle
//pen_size:=1;
//brush_style:=bs_solid;
draw_set_color(c_yellow); //The background color of the radar.
draw_circle(global.center_x,global.center_y,argument0,false);
with all
{
//if it isn't a controller and it is within distance
if object_index!=argument1 and point_distance(argument2,argument3,x,y)<argument4 then
{
draw_sprite_ext(sprite_index, -1,global.center_x+(x-argument2)/argument4*argument0, global.center_y+(y-argument3)/argument4*argument0, argument0/argument4,argument0/argument4,image_angle,c_white,1);
}
}
draw_set_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
//brush_style:=bs_hollow;
draw_circle(global.center_x,global.center_y,argument0,true);
 mike posted at 2007-04-30 20:17:47Quote
can you give me an example of what to write in the arguments. what would you recomend
 scorpafied posted at 2007-06-26 02:26:42Quote
i like that conversion of the script to gm6 its really useful it would work well in my game simon do you require credit
 Simon Donkers posted at 2007-06-27 08:11:48Quote
If you click the Creative Commons button at the top of the page besides the filesize you would read the license agreement stating that you can do pretty much anything if you give me credit.


Creative Commons License
 blue fire films posted at 2008-02-05 22:32:51Quote
ok i put the scrip in but it came up with a error "see below 4 error"

___________________________________________
FATAL ERROR in
action number 1
of Create Event
for object radar apaently:

COMPILATION ERROR in code action
Error in code at line 26:
draw_circle(global.center_x,global.center_y,argument0);

at position 55: Wrong number of arguments to function or script.



???? whats that about ????
 blue fire films posted at 2008-02-05 22:35:00Quote
oh wait i just relised im using game maker 7 any way i could get the code so that it works with gm 7
 tiger posted at 2008-07-10 10:28:00Quote
where do you put the argumaents?
 ktccd posted at 2008-12-05 12:50:23Quote
i believe i've gotten it to work in Gm7 (i think it is 7) but the latest error message i've gotten is about that i don't have pro edition. a number of arguments are missing and also, brush style hollow doesn't exist, and bs_solid would change to solid. hview and wview won't be recognised either.
 YYUU posted at 2009-01-25 11:38:30Quote
why are u guys even talking about GM5 and GM6!?!?!?!!?!? OMFG GM7 WAS RELEASED ABOUT 2 YEARS AGO....!!!!
 Adude posted at 2009-01-28 23:09:41Quote
This is good
 Shocker posted at 2010-05-07 13:37:45Quote
Example link doesnt work for me can you please upload it on mediafire or somewhere else just not share cash?Thanks
 Isaac posted at 2010-08-02 09:55:55Quote
A problem which seems to have happened to a few (most likely due to using later versions of game maker) seems to be the error at line 26. It doesn't pick up the outline argument, but says it has the wrong number of arguments to function for the script. This is especially weird as in the error message it states 'draw_circle(global.center_x,global.center_y,argument0);' even though in the code it's written as 'draw_circle(global.center_x,global.center_y,argument0,false);' so it seems to delete the last arguemtn 'false' when you play.
 Sinoco posted at 2010-09-13 12:21:23Quote
You people are idiots, and quite frankly i don't see how SD can handle such idiocy. Wrong number of arguments to function or script means you need more indices, specifically in this example the code changes between gm5 and 6 are that outlines are also taken into consideration. any real game maker user can adjust code from one version to another... jesus christ. tnx for radar script.
 Simon Varley posted at 2010-10-04 21:15:07Quote
Great work Simon, I cant believe people are so ungrateful for free scripts! Keep up the good work.

Reply

Name:
Site: