M
Maker90
Guest
I'm wanting to make a fog-of-war that allows the terrain to be seen, but the players, items, bullets, and so on, not be seen unless within LOS of a player. How can I do this? I am not against using a different fog-of-war system though I'd like to avoid doing this as the system I'm using now seems easier than the other method I've seen. I am currently using surfaces as it appears to be the more easily implemented system, but apparently there's another way to do it, using tiles, which I'm not familiar with.
The code of the oFogOfWar object that I'm currently using:
Create Event
Draw Event
Clean Up
As you can see, it currently redraws behind the player so they can't see where they were previously, only where they are at that exact moment. Which is what I want, with one exception. I want the map that I make (namely, the walls) to be visible, but nothing else. I'm using objects to make my map (namely, multiple instances of an oWall object).
The code of the oFogOfWar object that I'm currently using:
Create Event
GML:
fog_of_war = surface_create(room_width, room_height);
surface_set_target(fog_of_war);
draw_clear_alpha(c_black, 1);
surface_reset_target();
GML:
if (room == rGame)
{
if (!surface_exists(fog_of_war))
{
fog_of_war = surface_create(room_width, room_height);
surface_set_target(fog_of_war);
draw_clear_alpha(c_black, 1);
surface_reset_target();
}
draw_surface(fog_of_war, 0, 0);
}
surface_set_target(fog_of_war);
draw_clear_alpha(c_black, 1);
surface_reset_target();
surface_set_target(fog_of_war);
with (oLight)
{
gpu_set_blendmode(bm_subtract);
draw_sprite_ext(sprLight, 0, x, y, 2, 2, 0, c_white, 0.7);
gpu_set_blendmode(bm_normal);
}
surface_reset_target();
GML:
if (surface_exists(fog_of_war))
{
surface_free(fog_of_war);
}