Best/most efficient way to do fog of war on an infinitely generated map?

0 favourites
  • 2 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • I've got a top-down layout that uses seed generation and a tilemap to infinitely generate terrain. Whenever the player reaches an invisible edge of the layout, their position is reset and the tilemap is repopulated with their new offset co-ordinates.

    Terrain cannot be modified by the player, so I don't store any of the terrain information in an array or anything.

    I do want to include "fog of war" (FoW) though, hiding undiscovered tiles until the player gets close enough to them.

    I can't simply place a FoW layer that erases tiles the player gets near because the entire layout is being re-generated constantly. Instead I need to store the offset positions of cleared tiles, and I'm curious what is the most efficient way of doing this? I could make an array and place in every tiles offset X and Y, but that array will quickly get massive as its expected the player will be uncovering tens of thousands (if not more) tiles during their exploration.

    Suggestions? Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Keeping track of all the explored tiles is the only way to do it.

    You can find ways to have it take less space and you can store it in such a way as you don’t have to loop over all the spaces.

    You could store and load chunks of fog tiles every time you scroll. Say every quarter of the screen worth of tiles is a chunk. That way you only need to store what was changed.

    If you store the chunks in a dictionary you can keep the speed of accessing chunks constant. Also you could store the chunks as a string of 1’s and 0’s for fog or clear. Then you can do rle compression on it to make it more compact. Or there are more complex compression ideas.

    The data size would still increase but you should be able to slow how fast it increases.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)