How to create a fog of war effect?

Started by KyriakosCH, Thu 17/12/2020 21:07:23

Previous topic - Next topic

KyriakosCH

Something like in the known RTS games, eg Age of Empires series. Begin with the map being almost all unknown, and reveal parts if your units explore.
Any method? :)
This is the Way - A dark allegory. My Twitter!  My Youtube!

Snarky

How are you drawing the map in the first place? If it's tile-based, just have an "unexplored" graphic as the tile.

KyriakosCH

Ideally I would like the less blocky way of having the unit use the "line of sight" ability. Iirc someone had used a "flashlight" effect in AGS, so maybe there is some approach already? (eg a flaslight effect which leaves any area explored lit)

If it would be about tiles, to look decent it'd have to be done in a very different way, so first I would want to examine if the usual (eg as in AOE etc) style could work.

Otherwise, I suppose I could also mimic the tile effect (with the bulk of the map being just one image) using various small "fog of war" tiles which gets removed once the player moves on them.
This is the Way - A dark allegory. My Twitter!  My Youtube!

Crimson Wizard

#3
Technical solution follows design here, first determine how do you want this work logically, then it will be more clear how to implement this in the engine. But I do not know how your game's map is logically represented. Are units and other features located strictly on grid, or they are allowed to be positioned freely at any coordinates?

If your game is grid-based, then the fog of war and line of sight should also perhaps be grid-based. For grid-based maps the most perfomant way is ofcourse to draw tiles as "unknown tile". Alternatively, you could draw a ground layer tile and then half-transparent grey "fog" tile over it. Variants are numerous.

Line-of-sight mechanic can be implemented regardless, it could be in tiles, or in pixels.

Flashlight module in AGS works simply as drawing transparent spot on a black surface. Technically this may work for line of sight too, if you put this surface as an extra layer over your map (on object or GUI). The biggest problem is updating this as units move around, and finding most perfomant way to do so.

KyriakosCH

Thanks, I will ask again once (if; always have to allow for laziness  := ) there's a more set approach to the map from my part.
This is the Way - A dark allegory. My Twitter!  My Youtube!

SMF spam blocked by CleanTalk