greets
I intend to make a simple rpg but it would require fog of war (darkness over non-explored zones)
I'm sure it has been alrady asked before but I havent found anything like tutorials or such on this forum - do anybody know any example?
There are a variety of ways to accomplish this. The simplest would be to have many black active objects overlaying your map, which are destroyed when the player is within a certain distance. The only problem is that depending on your map size, this could slow down your game considerably.
Another method would be to have a grid of black active objects that follow the playfield (So the map moves, but the fog doesn't) then simply make them visible or invisible. This would take some of the strain off, but would be a bit harder to code.
Might be worth trying the Overlay object. Fill it with black, stretch it over the play area and draw transparent circles at the player's position whenever the player moves. The same technique used when creating a destructable terrain like in the worms games.
I haven't read any of the other answers. But the simple way is to just have an array that fills up with 1s (instead of 0 which is fog) as you explore the map. Then draw black objects on screen when you're near certain parts of it. That way you don't have objects off-screen taking up resources.