GMS 2 (Surfaces) Lighting for splitscreen

Hi this is my first forum post. So, I apologize in advance.

I need help with figuring out, how to.. uh, make lights.. be lights?

I want to make lighting, but only on where both screens see. (It’s splitscreen, two players)
I didn’t write this code, it’s from some tutorial somewhere. I just want to adapt it to a multiple view game.

So. I’m just having troubles with how the “with (oLight)” thing can draw lights.

Code:
var cw = camera_get_view_width(view_camera[0]);
var ch = camera_get_view_width(view_camera[0]);
var cx = camera_get_view_x(view_camera[0]);
var cy = camera_get_view_y(view_camera[0]);

var cw2 = camera_get_view_width(view_camera[1]);
var ch2 = camera_get_view_width(view_camera[1]);
var cx2 = camera_get_view_x(view_camera[1]);
var cy2 = camera_get_view_y(view_camera[1]);


if view_current = 0
{
    if surface_exists(surf)
    {
        surface_set_target(surf);
        draw_clear_alpha(c_black,Darkness);
        gpu_set_blendmode(bm_subtract);
        with (oLight)
            {
            draw_sprite_ext(sLight,image_index, x, y, image_xscale, image_yscale, image_angle,c_white,image_alpha);
            }
        gpu_set_blendmode(bm_normal);
        surface_reset_target();
        draw_surface_ext(surf,cx,cy,2,2,0,c_white,1);
    }
    else
    {
    surf = surface_create(cw,ch);
    }
}

///Second view

if view_current = 1
{
    if surface_exists(surf2)
    {
        surface_set_target(surf2);
        draw_clear_alpha(c_black,Darkness);
        gpu_set_blendmode(bm_subtract);
        with (oLight)
            {
            draw_sprite_ext(sLight,image_index, x, y, image_xscale, image_yscale, image_angle,c_white,image_alpha);
            }
        gpu_set_blendmode(bm_normal);
        surface_reset_target();
        draw_surface_ext(surf2,cx2,cy2,2,2,0,c_white,1);
    }
    else
    {
    surf2 = surface_create(cw2,ch2);
    }
}
Thank you in advance. This is something I’ve wanted to do for a while.. and was really hesitant about trying to post on here.
 
Top