i already have a code for the light system, but it also affects the background, pls halp.
here's the code for "obj_lightcontrol"
Create event:
global.light = surface_create(room_width, room_height)
Draw event:
var bbb = 1, i;
with (obj_lightspot){
xs = instance_nearest(x,y,obj_lightrand).xd
}
surface_set_target(global.light)/*With this function you set all further drawing to
the target surface rather than the screen and in this
way you can tell GameMaker:Studio to only draw
specific things to the specified surface.*/
draw_clear(c_black)//That line make the screen black
draw_set_blend_mode(bm_subtract)//We're starting to substract here
with (obj_lightspot){
for (i=0; i <= bbb; i+=1)//This line make the circle glow more
{
draw_sprite_ext(spr_light,0,x,y,xs,xs,0,c_white,1) //This is what we substract! A simple circle.
}
}
draw_set_blend_mode(bm_normal)//Important thing here! Stop to substract.
surface_reset_target()//With this function you reset all further drawing from the target surface back to the screen.
if surface_exists(global.light)//A safe way to avoid errors. If it exist, draw it. If not create it.
{
draw_surface(global.light,0,0)
}else{
global.light=surface_create(room_width,room_height)
}
The "obj_lightspot" is where all the lights are going to be created, this object just creates a "obj_lightrand" and this just randomizes the light size every step.
i want it to not affect the background. pleh
here's the code for "obj_lightcontrol"
Create event:
global.light = surface_create(room_width, room_height)
Draw event:
var bbb = 1, i;
with (obj_lightspot){
xs = instance_nearest(x,y,obj_lightrand).xd
}
surface_set_target(global.light)/*With this function you set all further drawing to
the target surface rather than the screen and in this
way you can tell GameMaker:Studio to only draw
specific things to the specified surface.*/
draw_clear(c_black)//That line make the screen black
draw_set_blend_mode(bm_subtract)//We're starting to substract here
with (obj_lightspot){
for (i=0; i <= bbb; i+=1)//This line make the circle glow more
{
draw_sprite_ext(spr_light,0,x,y,xs,xs,0,c_white,1) //This is what we substract! A simple circle.
}
}
draw_set_blend_mode(bm_normal)//Important thing here! Stop to substract.
surface_reset_target()//With this function you reset all further drawing from the target surface back to the screen.
if surface_exists(global.light)//A safe way to avoid errors. If it exist, draw it. If not create it.
{
draw_surface(global.light,0,0)
}else{
global.light=surface_create(room_width,room_height)
}
The "obj_lightspot" is where all the lights are going to be created, this object just creates a "obj_lightrand" and this just randomizes the light size every step.
i want it to not affect the background. pleh