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

Lights, Casters, Surfaces, Shadow blurs and the rest... A bit of a problem!

X

XirmiX

Guest
So, after much research and look at some ways of creating light and shadows and some extensions, I thought I would settle on using the Light and Shadows extension in order to create my lights and what not.

I read through the tutorial file and looked at the example file in order to get what I need. I also looked at this tutorial to get what I need in terms of the dark surface which would be applied to the entirety of a room:

So, I did some thinking, trying out and understanding some stuff and when I thought I finally got what I need... I didn't:


The shadows aren't working correctly and if I minimize the game and bring it up again, it'll give me this error:

Even though the surface has been set in the same goddamn object:
obj_lightControl Create event:
Code:
alpha = 1;
darkSurface = surface_create(room_width, room_height);
lightStrength = 1;

This is how the room looks like in the editor:

This is how I want it all to look like when the game is running:

P.S This was drawn edit from the next image, which is why parts of inaccuracy can be seen in places. I just wanted to give a general idea here.

And this is how it is actually rendering:

I believe the fault is in the shadow casting and the surface not being rendered for whatever reason, but I am unsure of how to fix this. I just tried to follow what I was given. So, considering all that, I'll just plop in all of the relevant code here:
obj_collisionbox Create event
Code:
caster_init_sprite();
obj_collisionbox Draw event
Code:
draw_self();
obj_lightControl Create event
Code:
alpha = 1;
darkSurface = surface_create(room_width, room_height);
lightStrength = 1;
obj_lightControl Draw event
Code:
surface_set_target(darkSurface);
draw_clear(c_black);
with(obj_light_spotlight)
{
    draw_set_blend_mode(bm_src_colour);
    draw_sprite_ext(spr_light, 0, x, y, image_xscale, image_yscale, 0, c_white, lightStrength);
    draw_set_blend_mode(bm_normal);
}
surface_reset_target();
draw_surface_ext(darkSurface, 0, 0, 1, 1, 0, c_white, alpha);
obj_lightmap Create event
Code:
lightmap_init(view_wview,view_hview);

lightmap_set_ambient(0.3); 
lightmap_set_light_parent_object(obj_light_parent); 
lightmap_set_caster_parent_object(obj_caster_parent); 
lightmap_move_with_view(true);
lightmap_set_shadows_enabled(true);
lightmap_set_shadow_size(256);
obj_lightmap Draw event
Code:
lightmap_update(); 
lightmap_draw();
obj_light_spotlight
Code:
lightStrength = 1;
light_init_sprite(spr_light,0);
image_alpha = 0.5;

On another note, once this is resolved, there is another detail I want to add to my lights, which is making shadows have a blur-like effect like it can be seen at 7:43 in this video:

But that's the step afterwards, I need the former to work right first, obviously.
 
Top