Skip to content

Instantly share code, notes, and snippets.

@collinticer
Last active July 11, 2020 16:35
Show Gist options
  • Save collinticer/525c71f5879ccdfcc7e9bde16c05cfc5 to your computer and use it in GitHub Desktop.
Save collinticer/525c71f5879ccdfcc7e9bde16c05cfc5 to your computer and use it in GitHub Desktop.
//the x and y coordinates of the crosshair center
var objectX = argument0;
var objectY = argument1;
//how far away to draw the track/circle
var distanceAway = argument2;
//width of the line of the circle
var width = argument3;
//the length of the pointer arrow
var pointerLength = argument4;
//color of the track and pointer
var trackColor = argument5;
var crosshairColor = argument6;
//alpha of the track and pointer
var trackAlpha = argument7;
var crosshairAlpha = argument8;
//whether to draw the pointer on the same side as the mouse or on the opposite side
var matchMouseSide = argument9;
draw_set_color( trackColor );
var mouseX = mouse_x;
var mouseY = mouse_y;
draw_set_alpha( trackAlpha );
for( var i = 0; i < width; i++ )
{
draw_circle( objectX, objectY, distanceAway + i, true );
}
draw_set_alpha( 1 );
draw_set_alpha( crosshairAlpha );
draw_set_color( crosshairColor );
var currentMouseDirection = point_direction( objectX, objectY, mouseX, mouseY );
var x1OfLine = lengthdir_x( distanceAway , currentMouseDirection );
var x2OfLine = lengthdir_x( distanceAway + pointerLength, currentMouseDirection );
var y1OfLine = lengthdir_y( distanceAway , currentMouseDirection );
var y2OfLine = lengthdir_y( distanceAway + pointerLength, currentMouseDirection );
if( matchMouseSide )
{
draw_arrow( objectX + x1OfLine, objectY + y1OfLine, objectX + x2OfLine, objectY + y2OfLine, pointerLength );
}
else
{
draw_arrow( objectX - x1OfLine, objectY - y1OfLine, objectX - x2OfLine, objectY - y2OfLine, pointerLength );
}
draw_set_alpha( 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment