• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Surface night/light problem

NicoDT

Member
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)


At night

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! :)
 

Xor

@XorDev
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!
 
R

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.
 

NicoDT

Member
Thanks for the replies

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!
But if I do that, then I wouldn't be able to "light" them, right? For example the light of a torch.


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.
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]

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.
 

Xor

@XorDev
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.
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.
 

NicoDT

Member
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.
By light them I meant something like this.
I don't know if it would be possible by blending all the tiles.

Anyway, I have found a solution.

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!
 
Top