1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Surface Duplicates When Return To Room

Discussion in 'Programming' started by T2008, Nov 6, 2019.

  1. T2008

    T2008 Member

    Joined:
    Jul 20, 2016
    Posts:
    185
    Edit: After several attempts to fix, I realized that the problem is related to the Lighting System 2d that I got from Spalding (with shaders, etc) is the problem (my code below works). It doesn't work with changing rooms. Anyone try to implement Spalding's light system and get it to work with change rooms?

    I'm drawing black surface and light sprite for torch. The problem is when I leave the room, it looks fine in adjacent room but when I return to original room, it doubles the black area to be super dark. I have no idea why. I place an obj_light_controller in each room, and torch creates object light.

    I tried draw_clear_alpha(c_white,0) and that didn't work.

    Edit: The doubling, etc appears in the room first created but not subsequent rooms.

    Any ideas would be greatly appreciated!!!

    Object Light Create Event:
    Code:
    surf = surface_create(room_width,room_height);
    surfScale = 1/8; //scaling light to appropriate size of room
    lightSize = 6;
    lightStrength = 1; //alpha of light (0 to 1)
    
    Object Light Step Event (light size):
    Code:
    var z = choose(.1,-.1,0);
    lightSize += z;
    lightSize = clamp(lightSize,6,8); //don't want it under 6 or over 8
    
    Object Light Draw Event:
    Code:
    surface_set_target(surf);
    draw_clear(c_black);
    //Torch Light
    if (global.torch_on) {
        with(obj_light1)
        {
            draw_set_blend_mode(bm_src_color);
            draw_sprite_ext(spr_light,0,((obj_player.x - 34) + (obj_player.sprite_width/2))*other.surfScale,((obj_player.y - 50) + (obj_player.sprite_height/2))*other.surfScale,lightSize*other.surfScale,lightSize*other.surfScale,0,c_white,lightStrength); 
            draw_set_blend_mode(bm_normal);
        }
    }
    surface_reset_target();
    //Draw Surface
    draw_surface_ext(surf,0,0,1/surfScale,1/surfScale,0,c_white,.5);
     
    Last edited: Nov 6, 2019
  2. T2008

    T2008 Member

    Joined:
    Jul 20, 2016
    Posts:
    185
    Edit: After several attempts to fix, I realized that the problem is related to the Lighting System 2d that I got from Spalding (with shaders, etc) is the problem (my code below works). Spalding's doesn't work with changing rooms. Anyone try to implement Spalding's light system and get it to work with change rooms?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice