[Solved] 8-Bit Bitmasking with Corner Tiles

I had a similar requirement for walls that I could just place in an editor and would change depending on the surrounding walls touching the newly placed piece. I also had written an extension for it.

I’ve taken your project, and modified it to use my extension, and updated the extension to fit in with your objects. The extension has 2 functions - one for 4 way checks (horizontal and vertical), the other for 8 way (4 way plus the diagonals)

Here is a link to the updated project.

And here’s how it looks - BTW, those dots in the middle are from the sprites in the project. It’s because of the 4-way check. It’s also a mess if I used 8-way, as there are animations missing. For example, a block with neighbours at 1 & 2. There is no block with an animation value of 3.

I realise in your code you allow for this by performing some checks, but that’s a bit of a hack to get around the problem that some animations are missing. Add those animations, even if they are duplicates of other ones. It makes the whole project less messy and less prone to errors/bugs.


Islands

1 Like