lighting a dark area using surfaces

W

Wild_West

Guest
I want to try and make a light that cuts out darker areas and allows the player to see.
My game focus is supposed to be a barrier gimmick, 100x100 surrounding the player of the same size.
I think the way to do this is with surfaces but I don't know how. Or am I wrong and need to do something else?
 

Simon Gust

Member
you can make a pitch black surface,
enable subtractive blending and draw a black circle onto the surface I believe

something like this:
Code:
if (!surface_exists(light_surface))
{
    light_surface = surface_create(view_xview, view_yview);
}

surface_set_target(light_surface);
draw_clear(0);
draw_set_blend_mode(bm_subtract);
draw_circle(obj_player.x - view_xview, obj_player.y - view_yview, 50, false);
draw_set_blend_mode(bm_normal);
surface_reset_target();
 
W

Wild_West

Guest
you can make a pitch black surface,
enable subtractive blending and draw a black circle onto the surface I believe

something like this:
Code:
if (!surface_exists(light_surface))
{
    light_surface = surface_create(view_xview, view_yview);
}

surface_set_target(light_surface);
draw_clear(0);
draw_set_blend_mode(bm_subtract);
draw_circle(obj_player.x - view_xview, obj_player.y - view_yview, 50, false);
draw_set_blend_mode(bm_normal);
surface_reset_target();
what's the draw_clear( 0 ) doing?
 
W

Wild_West

Guest
draw_clear fills the surface with a color, I could have used c_black but since c_black has the value 0 and I like short lines I put a 0 instead, it does the same thing.
Oh okay. It looks like it's working pretty good so far, but since I set it up in my practice file I'll have to test it in my real game to see if there's any issues to work out.
 
Top