Shading your map - AnselmeClergeot/FisoEngine GitHub Wiki
Shading your map is actually very simple. The only thing you will have to do is:
- Setting an invisible tile number to the shadows system
- Creating a shadows tileset
- Setting the tileset to the shadows system
- Call initialization of the shadows system
- Setting the shading system on
Let's start by setting the invisible tile number of our map. (For example 0)
myMap.setInvisibleTile(0);Let's continue by talking about our shadows tileset.
I hope you remember how do a tileset work: if you already forgot it, return reading the "Get started with Fiso Engine" tutorial. When it's done, you can go on!
The shadows tileset will be a tileset that contains all the shadows images of each tiles: these images will have to be aligned as the same way as the base map tileset.
For example: in our map tileset, our tile number 3 start at 100px: in our shadows tileset, the shadow image corresponding to tile number 3 will have to start at 100px.
In the tileset, do I have to set the shadows semi-opacity directly ?
No, you will have to set the shadows opacity parameter in the code directly. But of course, if you want to set a specific shadow more or less contrasted, you can operate directly on your image editing software (Remembers that shadows opacity are automatically modified by the opacity of the tile causing this shadow). So to be simple to start, set your shadows-tileset with all-black tiles. When it's done, your tileset should look like that:

(Sorry for the missing border... The only shadow starts at second tile coordinate, because the first one is the transparent tile).
So, we are ready to go next with coding. To access the shading system methods, here is how to do it:
myMap.shadows()//.someMethod()And here is the code block useful to initiate the shading system:
myMap.shadows().setTileset("myShadowsTileset.png"); //Setting the tileset to the system.
//THE SYSTEM IS UNAVAILABLE...
myMap.shadows().init(); //Order to start calculating/initiating the system.
//THE SYSTEM IS NOW AVALAIBLE!
myMap.shadows().setOpacity(128); //Setting the shadows opacity.
myMap.shadows().setStatus(fe::Status::On);//And finally, setting the system on. Or off if you want.Note that the opacity parameter must be greater or equal than 0 and lower or equal than 255.
You can get the opacity of the shadows by doing:
myMap.shadows().getOpacity();How do I do for tiles that should not generates and receives shadows? I mean like water, etc?
Let's talk about translucent tiles. For example, if the water tile corresponds to the number 4, you will have to add a translucent tile number to the map by doing:
myMap.addTranslucentTile(4);And you can add as many translucent tiles as you want. As the same way, you can remove a translucent tile number from the list by doing:
myMap.removeTranslucentTile(yourTileNumberToRemove);You can now admire your beautiful shaded map!