I wanted to add some sort of water area’s to the cave generation, and I used some simple trickery to come up with a very simple and quick solution. It’s a bit dirty in the sense of having flaws, but the rendering speed makes up for it.
I basically generate a random value for the waterlevel, this is the height of the water calculated from the bottom of the cave. Everything from that line and below will be seen as water.
At the rendering phase we render the level in the normal way, render all the tiles, monsters, creatures, etc. When everything is on the screen we overlap a blue image from the waterlevel downwards with a specific alpha transparency, and make sure the center of the map is at the center of the player so that it fits with the lighting surrounding the player.This is the “water” map image:
As you can see the image already has the edges in darker colors to mimic the light used in the game: the further away from the player, the darker it is.
And this is how it looks in-game if the player is still above the water-level (watermap only rendered at the waterlevel and below):
And how it looks if the player is completely under the water level (the watermap image simply rendered on-top of the full screen):