V
function radiandrawer(x,y,dir,size){
var i;
for (i = 70; i != 0; i -=1)
{
var checkedsize = size ;
var c;
var unchecked;
unchecked = true
for (c = 0; c != size && unchecked ; c += 5)
{
if !place_empty(x+xfinder(c,dir+i-35),y+yfinder(c,dir+i-35),obj_wall)
{
unchecked = false;
checkedsize = c;
}
}
draw_line(x,y,x +xfinder(checkedsize,dir+i-35),y + yfinder(checkedsize,dir+i-35));
}
}
function xfinder(c,alphadir){
fx = c * dcos(alphadir)
return fx;
}
function yfinder(c, alphadir){
fy = c * dsin(alphadir)
return -fy;
}
draw_set_colour(c_lime);
radiandrawer(x,y,direction, 400)
draw_text(100, 100, direction);
draw_self()
the code is finding a collision with the wall if it were to hypothetically place the player object at those points.You can use this function to check and see if the calling instance would collide with any other instance in your game. Now, it should be noted that for this to work, the instance running the code must have a valid collision mask (either for the sprite itself, or through the mask_index.) and it will only register collisions with those instances that also have a valid mask.
The function itself basically works by taking the instance and testing for collisions when placed at the position specified by the x/y arguments. The collision checking can be either precise or based on the bounding box of the instance, depending on what kind of collision mask has been selected.