SquiggleyPete
Member
I'm setting up a basic lighting system in my game. There are two objects involved; obj_lighting, which creates the surface and handles all the drawing, and obj_light_source, which I place in the room at points where I want there to be a light source.
I've put a variable in creation code of the obj_light_source called tint_color that is meant to allow for changing their color. I put some lights in the room, opened their creation code, and set the tint_color variable to c_red. In game, however, they are all being drawn as white. I tried upping the alpha on the light sources all the way to 1, but that didn't seem to help.
Relevant code (being run in obj_lighting draw event):
The obj_light_source objects do not have a draw event.
Some of the above code is likely irrelevant (like spotlight on player and tinting the surface) but I left it all in just in case.
Thanks!
I've put a variable in creation code of the obj_light_source called tint_color that is meant to allow for changing their color. I put some lights in the room, opened their creation code, and set the tint_color variable to c_red. In game, however, they are all being drawn as white. I tried upping the alpha on the light sources all the way to 1, but that didn't seem to help.
Relevant code (being run in obj_lighting draw event):
Code:
/// draw surface, blend, draw lights
if !surface_exists(light_surface)
{
light_surface = surface_create(width,height);
}
else
{
draw_surface(light_surface,0,0);
surface_set_target(light_surface);
draw_set_alpha(dark);
draw_set_color(c_black);
draw_rectangle(0,0,width,height,false);
if tint == true
{
draw_set_alpha(tint_amount);
draw_set_color(tint_color);
draw_rectangle(0,0,width,height,false);
}
draw_set_color(c_white);
if spotlight == true //spotlight on player
{
gpu_set_blendmode(bm_subtract);
draw_set_alpha(.5);
draw_sprite(spr_light_64,image_index,obj_player.x,obj_player.y-6);
gpu_set_blendmode(bm_normal);
}
//draw light sources
if instance_exists(obj_light_source)
{
with obj_light_source
{
gpu_set_blendmode(bm_subtract);
draw_sprite_ext(sprite_index, image_index, x, y, xsize, ysize, 0, tint_color, alpha);
gpu_set_blendmode(bm_normal);
}
}
Some of the above code is likely irrelevant (like spotlight on player and tinting the surface) but I left it all in just in case.
Thanks!