I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: Realtime911 on April 06, 2016, 03:57:29 AM

Title: Spotlight Effects From Kill The Guy?
Post by: Realtime911 on April 06, 2016, 03:57:29 AM
How do I make the spotlight effect like in kill the guy, it seems very flexible. Up until now, I use sprite as an spotlight effect, but that doesn't help me if there's two or more light sources

Any help is appreciated!
Title: Re: Spotlight Effects From Kill The Guy?
Post by: L4Vo5 on April 06, 2016, 10:06:26 AM
I tought about making a surface where everything is black (with low alpha if you want) and somehow making whole sections (the sections where the light would be on) be removed, but i don't know if you can really remove sections like that (maybe with shaders?)
Title: Re: Spotlight Effects From Kill The Guy?
Post by: WetWookie on April 06, 2016, 11:14:25 AM
You're just about right. You create a surface and draw a black rectangle. The alpha you use when drawing the rectangle determines how dark it is where there is no light. Alpha of 1 is pitch black. Alpha of 7 is gloomy but visible. You then set the draw mode to subtract draw_set_blend_mode(bm_subtract); and draw your 'light' sprites at the location of all your light sources which removes the blackness of the rectangle you drew earlier. Set draw mode back to normal and draw your surface.
Title: Re: Spotlight Effects From Kill The Guy?
Post by: lawatson on April 06, 2016, 02:42:35 PM
Just be wary that bm_subtract likes to be a bitch with certain effects, so things like draw_set_blend_mode_ext(bm_dest_alpha,bm_inv_src_alpha) might work better assuming you have surface code which would work with it correctly.
Title: Re: Spotlight Effects From Kill The Guy?
Post by: Realtime911 on April 06, 2016, 07:49:07 PM
ah, I'm sorry but I'm still new to these draw codes so I'm still a bit confused, can you make an example for it?
Title: Re: Spotlight Effects From Kill The Guy?
Post by: chalenged on April 07, 2016, 08:58:02 PM
Here's a nice example for Studio:
https://zackbellgames.com/2015/01/19/simple-lighting-surfaces/
Title: Re: Spotlight Effects From Kill The Guy?
Post by: Realtime911 on April 09, 2016, 06:57:25 PM
Aah yes, it's working!. Thanks everybody, I appreciate it!