Regenerating Fog of War

R

RedSPINE

Guest
Hello guys !

I'm new here because I recently purchased the Humble Bundle's GM Suite and I'm trying my best to discover the software by challenging myself to do reaaly small games, espcially to make myself think on mechanics and how to code them.

Last Night, I set my objective to create a small game where a little ghost explore a forest at night with his lantern. What I wanted to is a fog around the ghost that make everything out of the lantern's light range invisible, or at least, really dark.
The problem is, I don't know how to us the "Draw" elements, and I don't really know how to do it, I watched some Youtube tutorials, but I don't understand the code, even if I see that it works, I would like to understand why they are doing this or that in order to do it myself the next time.

Would you recommend me checking other tutorials and which ones ? I don't really find what I want. Or if you could just explain me how you make the fog of war around your character and regenerating behind him.

Sorry if I did some language errors, I'm not a native english speaker, and I'm trying my best :)

Thank you
 
Q

Quackertree

Guest
Best way to achieve this is by taking a radial gradient such as this one, then applying the bm_multiply blend mode. All black pixels will become black on screen, and all white pixels will become the actual colour of the screen.

Should be overlayed in the Draw GUI event.
 
R

RedSPINE

Guest
I understand how it works, even I don't know at all this Qt Library. But I don't know how and where to us multiply to mask all the objects and background around the player, is there a way to put it in the player object or do I need to put it in the room code ?
 
K

Kululu17

Guest
Try looking up one of the lighting tutorials using surfaces. The effect I think you are trying to get is pretty easy to do with that. Basically, you create a surface, superimpose a gradient "hole" centered above your character, then draw that surface above everything else. The surface would then block everything except where there is the "hole".


This is one tutorial, but just look for "lighting surface" in youtube, and there's a bunch more.
 
Top