1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Surface night/light problem

Discussion in 'Programming' started by NicoDT, Jun 27, 2016.

  1. NicoDT

    NicoDT Member

    Joined:
    Jun 21, 2016
    Posts:
    237
    Hello everyone!

    I'm trying to figure out a problem I have, but had not luck yet.

    During day (the skill looks horrible the way it is right now, pay no attention! haha)
    [​IMG]

    At night
    [​IMG]

    I'm appliying a night surface with the size of the screen. The thing is I want certain skills (like fire) not to become dark.
    So far, it works. The problem is that with the way the code works, it doesn't take into consideration depth, and as you can see in the second picture, the skill's "light" is visible even behind the tree (and other tiles)

    Code:
    if !surface_exists(night_surface)
        {
         night_surface = surface_create(room_width, room_height)
        }
        else
        {
            surface_set_target(night_surface)
            draw_clear(c_black)
           
             with (obj_animation_aux) {
                if (light = true) {
                 if (sprite_index != -1) {
                 draw_set_blend_mode(bm_src_color);
                 draw_sprite_ext(sprite_index,image_index,x-view_xview,y-view_yview,image_xscale,image_yscale,image_angle,image_blend,0.85)
                 draw_set_blend_mode(bm_normal)
                 }
                }
            }
           
                   
            surface_reset_target();
           
            draw_surface_ext(night_surface,view_xview,view_yview,1,1,0,c_white, night_alpha)   
        }
    

    Any help with how I should approach this is really appreciated! :)
     
  2. Xor

    Xor @XorDev

    Joined:
    Jun 20, 2016
    Posts:
    76
    Try without a surface. Simply drawing all the sprites with different image_blends. Here's an example:
    Code:
    var C = merge_colour(image_blend,0,0.15*light);//Determine a light color
    draw_sprite_ext(sprite_index,image_index,x-view_xview,y-view_yview,image_xscale,image_yscale,image_angle,C,image_alpha);
    
    Let me know if you can make that work!
     
  3. Robert

    Robert Guest

    Im not really sure how you are doing things, but if you night/light effect is just a surface why can't you simply draw the skill effect on top of it? That would seem like a simple enough solution.
     
  4. NicoDT

    NicoDT Member

    Joined:
    Jun 21, 2016
    Posts:
    237
    Thanks for the replies

    But if I do that, then I wouldn't be able to "light" them, right? For example the light of a torch.


    The thing is that the tree (and other tiles) have different depths.
    Right now it would be something like * skill sprite > tree tile > night surface * , if I draw the sprite over the surface, then it would also appear above the tree.


    [​IMG][/IMG]
    [​IMG]

    This picture is more clear.
    In picture 1 and 2 the object (skill) is drawn correctly, appearing in front (1) and behind (2) the tree.
    In picture 3, it is also drawn correctly, as I'm appliying the light with the shape of the sprite (circle).
    But in picture 4, as the light is is drawn on the surface, it is also iluminating the front of the tree, when I would need something like picture 2.
     
  5. Xor

    Xor @XorDev

    Joined:
    Jun 20, 2016
    Posts:
    76
    You would darken them at night unless they glow. That way you have control of all the objects while drawing them as usual except you change the image_blend at night.
     
  6. NicoDT

    NicoDT Member

    Joined:
    Jun 21, 2016
    Posts:
    237
    By light them I meant something like this.
    [​IMG]
    I don't know if it would be possible by blending all the tiles.

    Anyway, I have found a solution.
    [​IMG]

    What I did was add another surface above the night surface.
    This new surface had the circle and the darkened tiles drawn.

    It may not be the fanciests way, but it seems to work for now haha.
    Thanks!
     

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