P
_Proxy
Guest
I'm trying to make a cone flashlight with my lighting system but its not keeping the same size as its rotating.
buffer_x and buffer_y is the tip of the gun
length_x and length_y is the length of the triangle
(x-2) and (y-2) is the origin on the gun
Code:
// Flashlight
if (flash_light) and (flash_light_toggle)
{
var c = make_colour_rgb(255, 255, 255);
var dir = point_direction(x, y, mouse_x, mouse_y);
var buffer_x = lengthdir_x(18, dir);
var buffer_y = lengthdir_y(18, dir);
var length_x = lengthdir_x(200, dir);
var length_y = lengthdir_y(200, dir);
gpu_set_blendmode(bm_subtract);
surface_set_target(light);
draw_triangle_colour
(
(x-2) + buffer_x - camera_get_view_x(view),
(y-2) + buffer_y - camera_get_view_y(view),
(x-2) + length_x - camera_get_view_x(view),
(y-2) + length_y - camera_get_view_y(view),
(x-2) + length_x - camera_get_view_x(view),
(y-2) - length_y - camera_get_view_y(view),
c,c,c, false
)
surface_reset_target();
gpu_set_blendmode(bm_normal);
}
buffer_x and buffer_y is the tip of the gun
length_x and length_y is the length of the triangle
(x-2) and (y-2) is the origin on the gun