I got a little bored so I decided to throw together a script that draws a simple line of col1 and col2, based upon range_finder(). The lite version will draw only col.
Pro / Standard...
Spoiler
An example of use would be...
/* draw_laser()
** by MasterOfKings
** based on range_finder()
**
** General form: draw_laser(x,y,dir,range,obj,col1,col2)
**
** Argument list..
** argument0 (x) : Starting x coordinate
** argument1 (y) : Starting y coordinate
** argument2 (dir) : Direction of laser
** argument3 (range) : Maximum range of laser
** argument4 (obj) : Object which blocks the laser
** argument5 (col1) : First colour
** argument6 (col2) : Second colour
**
** Usage: Draws a laser which can be blocked by obj.
*/
var dx,dy,xx,yy;
dx=lengthdir_x(argument3,argument2);
dy=lengthdir_y(argument3,argument2);
xx=argument0+dx;
yy=argument1+dy;
if (collision_line(argument0,argument1,xx,yy,argument4,true,true)!=noone) {
while ((abs(dx)>=1) || (abs(dy)>=1)) {
dx*=0.5;
dy*=0.5;
if (collision_line(argument0,argument1,xx,yy,argument4,true,true)!=noone) {
xx-=dx;
yy-=dy;
}
else {
xx+=dx;
yy+=dy;
}
}
}
draw_line_color(argument0,argument1,xx,yy,argument5,argument6);An example of use would be...
if (keyboard_check(vk_space)) {
draw_laser(x,y,direction,1000,objWall,c_red,c_orange);
}Lite...
Spoiler
An example of use would be...
/* draw_laser()
** by MasterOfKings
** based on range_finder()
**
** General form: draw_laser(x,y,dir,range,obj,col)
**
** Argument list..
** argument0 (x) : Starting x coordinate
** argument1 (y) : Starting y coordinate
** argument2 (dir) : Direction of laser
** argument3 (range) : Maximum range of laser
** argument4 (obj) : Object which blocks the laser
** argument5 (col) : Colour
**
** Usage: Draws a laser which can be blocked by obj.
**
** Note: Can be used in Lite.
*/
var dx,dy,dc,xx,yy;
dx=lengthdir_x(argument3,argument2);
dy=lengthdir_y(argument3,argument2);
dc=draw_get_color();
xx=argument0+dx;
yy=argument1+dy;
if (collision_line(argument0,argument1,xx,yy,argument4,true,true)!=noone) {
while ((abs(dx)>=1) || (abs(dy)>=1)) {
dx*=0.5;
dy*=0.5;
if (collision_line(argument0,argument1,xx,yy,argument4,true,true)!=noone) {
xx-=dx;
yy-=dy;
}
else {
xx+=dx;
yy+=dy;
}
}
}
draw_set_color(argument5);
draw_line(argument0,argument1,xx,yy);
draw_set_color(dc);An example of use would be...
if (keyboard_check(vk_space)) {
draw_laser(x,y,direction,1000,objWall,c_red);
}Edited by MasterOfKings, 24 February 2012 - 08:37 AM.











