In my current project I have tiles which represent a certain type of terrain. Each of these types have their own coloured tile image. This all works very well but I also want to be able to represent a water/water depth value on top of a tile if there is water.
I would like to colour the tiles as they are outputted by setting the tiles color with a sf::color value where an higher water depth would mean an stronger blue.
I am currently using the following code:
if(Displayed_Tiles[x][y].is_Water())
{
Rendering_Tiles[x][y].setColor(sf::Color(125,125,255/(Displayed_Tiles[x][y].Get_Water_Saturation()),255/2));
}
Where Displayed_Tiles
- [y].Get_Water_Saturation() is an number over 1 which goes down lower as the water depth increases. This code is called each time I draw the tiles to the screens. After the tiles have been draw I "flash" all Rendering_Tiles which means I reset their colour.
The problem is that it doesn't work, in two ways. The tiles aren't colored blue, no matter the water depth and the tiles color does not change if their water depth is decreased/increased.
Anyone have any clue of why the code isn't working or what steps I should take to remedy it?(Or recommend me a better system to colour the tiles according to a water depth variable?).
Sorry if an topic similar to this has been posted. Searched around on the graphics and general boards but couldn't find anything relevant to this topic.