Fog of war

My game relies on fog of war. So far the only way I can think of to implement this is to use a tile map. I’m wondering is there is a better approach. Anyone have some insight on how I would go about doing this? [import]uid: 8434 topic_id: 4799 reply_id: 304799[/import]

you could possibly layer a black layer with an alpha’d hole in the centre over the top of your screen/character (ie a gradient mask), but i dont know how much this would slow down your performance

[import]uid: 6645 topic_id: 4799 reply_id: 15384[/import]

That looks a lot better than my tile map version. I’m going to have to try it out and see how well it performs. [import]uid: 8434 topic_id: 4799 reply_id: 15428[/import]

depending on your graphic you could potentially also scale it up to make the view wider…or alternatively swap a new graphic in.

j. [import]uid: 6645 topic_id: 4799 reply_id: 15434[/import]

I’ve been trying to put an alpha’d hole on a black layer, but have failed. Any chance you could post the code for doing that? Thanks! [import]uid: 25480 topic_id: 4799 reply_id: 18282[/import]

if you wait till tomorrow evening it may be possible that we get the “masking” feature request. this will help.

but as far as your suggestion so far, you need to create this as a png in photoshop/fireworks etc. a black square with a hole in the middle. it’s not a code thing

j

[import]uid: 6645 topic_id: 4799 reply_id: 18299[/import]

Ah, understood. Thanks! [import]uid: 25480 topic_id: 4799 reply_id: 18301[/import]

I’m glad this seems to have solved his issue, but this isn’t really fog of war. Fog of war isn’t simply a view radius beyond which things are too dark to see, it’s obscuring areas you haven’t been to yet. Think about most real-time strategy game; you can’t see what’s in areas of the map you haven’t explored yet.

The expression “fog of war” doesn’t refer to a literal fog, but is a metaphor for lacking information about areas of the battlefield that you don’t have scouts watching. [import]uid: 12108 topic_id: 4799 reply_id: 18375[/import]

jhocking: that’s exactly what I’m trying to do. I hope the masking feature will allow it. Right now I got it working as a tile map but it doesn’t look “great”. [import]uid: 8434 topic_id: 4799 reply_id: 18401[/import]

Fog of war must be implemented as a tile map in order to dynamically change which tiles are covered. The fact that it’s a tile map doesn’t mean it’ll look bad. What’ll make it look bad is bad tiles.

In particular, your tiles don’t have to be perfect squares. Tiles for fog of war should be hazy at the edges, so you’re going to need a set of tiles for a hazy edge on one side, two hazy edges on a corner, hazy edges on opposite sides, and a tile with hazy edges on all four sides. [import]uid: 12108 topic_id: 4799 reply_id: 18422[/import]

ah ok that’s a different problem then, maybe you could overlay extra graphics for each tile to darken it, but this would be a performance-hog to some extent. if we get sprite tinting in the next release this will help, rather than having to store multiple versions of the tile

j [import]uid: 6645 topic_id: 4799 reply_id: 18423[/import]

only skimmed this… wouldn’t masking work?

c [import]uid: 24 topic_id: 4799 reply_id: 18435[/import]

not exactly carlos… my misunderstaning… as jhocking mentions, “Fog of War” is not a set shape as such, it is a representation of areas of the map that have not been visited. this wouldn’t be a fixed shape.

effectively you’d be checking each tile for it’s distance from the visited tiles and coloring accordingly

eg if i go up, more of the northern tiles light up, whereas if i go left more of the western tiles light up

here’s an example of FOW without gradient/alpha-ing


from http://houseslasher.com/index.php?showtopic=50 [import]uid: 6645 topic_id: 4799 reply_id: 18443[/import]

like i said previously, i didn’t read the whole post. but maybe squares with transparency? level of transparency ? maybe someone said it before or am just mentally fried.

i will visit this once we ship

where is my coffee? [import]uid: 24 topic_id: 4799 reply_id: 18448[/import]

but that would mean using 2 sprites per tile in some circumstances (original + overlay). although with the original poster’s design, presumably he could just set the alpha of the original tile against a black background.

but i’m waiting to see if we’ve got any new graphics options later :stuck_out_tongue:
[import]uid: 6645 topic_id: 4799 reply_id: 18506[/import]