MonkeyLover
Member
I'm 4 days into making my game and I want a glitch effect for when enemies are damaged, I found bktGlitch which is a really, really good shader from what I can tell. It is meant for use on the application_surface. However, I'd love to use it on my o_simpleEnemy. So I figured out how to make my own surface, called o_surface, and I attached it to my o_simpleEnemy. I'm having trouble actually drawing the shader onto the surface though, no matter what I do it always draws onto the application_surface even when I do not input it into draw_surface. I know this is a very specific issue, but I really don't know what else to do, as I have been performing trial and error on this issue and watching videos about surfaces for the entire day and I need some ideas because I'm out. So I would really appreciate it : )
My code for the create event of o_surface is just:
Here is my code for the draw event of o_surface. This code will cause the shader to apply to the entire screen until the hitflash animation is over, despite the surface clearly being set to "surface" instead of the application_surface. When bktglitch_deactivate(); is enabled, the code does nothing visually. I'm wondering if maybe, despite the "surface" size being set to 16 x 16, if it is stretching that 16 x 16 specifically across the entire application_surface. But to check where "surface" is I used draw_clear_alpha(c_white, 1); and it fit exactly in the place I wanted it to, on top of o_simpleEnemy. I also put the same draw_clear_alpha(c_white, 1); in the top part instead of the else area to see if it was distorting for just the top and got the same result.
As I said earlier, I know this is a super specific issue, but any help or advice would be appreciated.
My code for the create event of o_surface is just:
Code:
surface = surface_create(16, 16);
Code:
if (surface_exists(surface))
{
if(o_simpleEnemy.flash > 0)
{
surface_set_target(surface);
bktglitch_activate();
bktglitch_config_preset(BktGlitchPreset.B);
draw_surface(surface, o_simpleEnemy.x-8, o_simpleEnemy.y-8);
//bktglitch_deactivate(); //same as shader_reset();
surface_reset_target();
}
draw_surface(surface, o_simpleEnemy.x-8, o_simpleEnemy.y-8);
}
else
{
surface = surface_create(16, 16);
surface_set_target(surface);
//draw_clear_alpha(c_white, 1);
surface_reset_target();
}
Last edited: