Fog of war
Hello everyone! Progress has been made, and it's time to brag.
As I mentioned before, I was working on the enemy pod activation mechanism. I will post more details about it in a few days however, as the first thing that had to be finished is the line of sight mechanism.
Basically there was no such mechanism in place until now. The player always saw the whole map. That had to be changed somehow.
Now, XCom used the standard fog of war implementation - basically each map tile can be:
- Unknown (which then is basically invisible)
- Uncovered, and observed at the moment a.k.a visible (the player has full information about what is going on on the tile)
- Uncovered, but not observed at the moment (the player can "see" the tile, but has no information about enemies on it)
I have decided to use similar yet simplified solution, which only uses two of the states above: unknown and visible. This means that after the player uncovers a tile, they get full information about its content until the end of the combat.
Anyway, the technical implementation of field of view calculation was not that difficult - doing 360 degree raycasts worked like a charm, and didn't influence the performance at all (possibly the fact that the game is turn-based did help here significantly).
The hidden tiles simply had a darker color applied to their sprite renderers. However, I did want to make the fog of war to be displayed in a smoother way. Google mentioned that one can use the approach with rendering stuff to texture, and applying an extra layer on top of the displayed stuff.
In the end I started using the SpriteLightKit library for this, and I ended up with this effect:
Although it is still far from perfect, it looks more pixelated.
Now, firing the raycasts from the current player location was not enough - because the assumption is that characters can lean out of covers, effectively seeing more.
See the screenshot below - the character should see the stuff on the right, behind the pillar:
I have altered this as well so that stuff visible after potential leaning out is also visible to the player. It is possible that the player is seeing a little bit too much (not sure whether the tile to the right of the rightmost pillar should be visible), but that's desired:
Anyway, this concludes the part about field of view. Next time I will show you how I have used it in the enemy pod activation mechanics.
Take care!
Shardpunk: Verminfall
A tactical squad-based survival strategy game based in a thoroughly stylised pixel-perfect steampunk setting.
More posts
- Devlog #140: Shardpunk is now live!Apr 13, 2023
- Devlog #139: Less than a week to launch!Apr 07, 2023
- Devlog #138: Release date reveal!Mar 24, 2023
- Devlog #137: Can a game be truly fair?Mar 04, 2023
- Devlog #136: Reflections on Next FestFeb 17, 2023
- Devlog #135: hand-holding tutorialJan 27, 2023
- Devlog #134: shelter phase changesJan 27, 2023
- Devlog #133: 2022 wrap-upDec 31, 2022
- Devlog #132: playtests in progressNov 25, 2022
- Devlog #131: combat tactics, and moreNov 12, 2022
Leave a comment
Log in with itch.io to leave a comment.