• 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 Some help with a (seemingly) peculiar issue with surfaces?

R

Rosieu

Guest
Hi again everyone!

Sorry to be bugging the forums (yet) again, but I have run into an issue with drawing to a surface that for the life of me I can't seem to fix, or even debug.

The idea was to create a surface to deal with simplistic lighting effects utilizing blend modes and the like, however the obj that initializes the surface (or any other object for that matter) seems to refuse to draw sprite / primitive / shape / whatever, other than the original draw_clear_alpha(). It doesn't seem to be an issue with the Boolean logic, as the draw_clear_alpha() functions regardless of which branch of the 'if' I place it under, however it simply will not draw anything else. Likewise I don't think it's an issue of depth, as the object's depth is set to -100000, and the sprites (etc) to draw were placed after the draw_clear_alpha in the code.

I'll include the code because it's (probably) some stuipid mistake on my part, but it's driving me up the wall! :O

Code:
if(surface_exists(global.light_surface))
{
    surface_set_target(global.light_surface);
    draw_set_blend_mode(bm_normal);
    draw_sprite_ext(spr_light,0,x,y-8,1,1,0,c_white,1);
    draw_set_blend_mode(bm_normal);
    surface_reset_target();
    draw_surface(global.light_surface,view_xview[0],view_yview[0]);
    
}
else
{
    global.light_surface = surface_create(view_wview[0],view_hview[0]);
    surface_set_target(global.light_surface);
    draw_set_blend_mode(bm_normal);
    draw_clear_alpha(c_white,0.5);
    draw_set_blend_mode(bm_normal);
    surface_reset_target();
}

Thanks in advance for any help everyone can give!
 

Kahrabaa

Member
You might be drawing the sprite outside of the surface.

Edit: Try this
Code:
draw_sprite_ext(spr_light,0,x-view_xview[0],y-view_yview[0]-8,1,1,0,c_white,1);
Since drawing something to a surface starts at the surface origin.
Drawing a sprite at its x and y. Will add that position to the view position which will give a incorrect coordinate. Maybe
 
Last edited:
R

Rosieu

Guest
Thanks for the reply! That seemed to do the trick!

It took me a minute to work out why, but that is some very handy info to have. Thanks so much for clearing up a peculiarity of surfaces that has been driving me a little bit insane! :D
 
Top