I have an object that is dealing with lighting effects. Basically it's creating a surface that covers the viewport, drawing a dark rectangle on it, and then essentially "poking out" holes by drawing circles and blending the colors together. At the moment Im trying to achieve the lantern effect. Everything seems to be working fine, except the surface wont follow the player object correctly. Either the dark rectangle is drawn over the viewport and the circle doesnt follow the player until youre close to the views x,y origin, OR the rectangle only draws at the rooms x,y origin not following the view but when you enter that area the circle follows you perfectly. I hope this makes sense. Heres the code.
Create
surf = surface_create(302,243);
color = make_color_rgb(8,8,40);
surface_set_target(surf);
draw_clear_alpha(c_black, 0);
surface_reset_target();
Step
if (surface_exists(surf)) {
surface_set_target(surf);
draw_set_color(color);
draw_set_alpha(.8);
draw_rectangle(0,0,302,243,0);
draw_set_blend_mode(bm_subtract);
draw_set_color(c_white);
if global.item_obtained[0] = true {
draw_circle(objLink.x+7,objLink.y+14,16,false);
draw_set_alpha(.5)
draw_circle(objLink.x+7,objLink.y+14,32,false);
}
draw_set_blend_mode(bm_normal);
draw_set_alpha(1);
surface_reset_target();
} else {
surf = surface_create(302, 243);
surface_set_target(surf);
draw_clear_alpha(c_black, 0);
surface_reset_target();
}
Draw
if (!surface_exists(surf)) {
surf = surface_create(302, 243);
} else {
if (view_current == 0){
draw_surface(surf, 0, 0);
}
}
The changes happen when I change x,y position of draw_surface in the Draw event, either 0,0, or view_xview+0,view_yview+0.