Now it’s time to connect up the auto-tile logic. We’ll start by counting up each neighbor and converting that binary string into an Int32 then assigning a sprite to it.
- [Voiceover] Now it's time for us to calculate…the autotile ID for each of our tiles,…based on the neighbors on each of their sides.…Now let's go back into our tile class,…and create a new public field…that's typed to int called autotile ID.…Next, we're gonna need to import…some new name spaces.…We'll start by importing System…and then after that we'll use System.Text…because calculating the bit shifting…is a little bit complicated if this…is your first time doing it,…we're going to cheat a little bit…and try to make this as simple…to visualize as possible.…
In order to create a binary number,…we're gonna make a string,…where each position of the string…represents a side adjacent to the…neighbor of the tile.…This way, if a neighbor exists, we'll set a one.…And if it doesn't exist, we'll set it to zero.…We'll then convert that string into an int.…And this will give us the correct ID…to map for our auto-tiling system.…To show you how this works,…let's go ahead and create a new,…private method called CalculateAutotileID.…
Released
5/16/2016- Setting up the project
- Creating the tile, map, and map tester classes
- Visualizing the map
- Creating a moving camera
- Autotiling and bit shifting
- Decorating the map
Share this video
Embed this video
Video: Calculate auto tile values