Shattering scenery

Since I first implemented foreground layers, like the little bits of vegetation that grow on things, there’s been a bug where when a collision layer tile is destroyed, any foreground tile growing off of it stays around, floating in thin air. That’s OK for some tiles, but not others. Here’s a video featuring this bug:

I fixed that bug today, mostly. Now certain foreground tiles are designated as being attached to a collision layer tile, and get destroyed along with them. Take a look:

There’s still a bit more work to do — this only works with foreground tiles that haven’t been rotated and that are located above their attachment point. To handle rotated tiles attached to arbitrary surfaces, so that the vegetation is growing out of the side of rocks, for example, I have to once again wrap my mind around the way that Tiled stores its tile map data. Each tile can be arbitrarily rotated as well as flipped horizontally and vertically. This is reduced internally to a bit field that records mirroring on the X axis, Y axis, and diagonally. It’s still not obvious to me how these three bits correspond to arbitrary rotations and mirroring of tiles, and while figuring it out I found a bug in my earlier tile code. I enabled some debug output with known patterns of tiles to help me figure out what was going on in the data.

Not a cave drawing or art nouveau. Only for debugging purposes.

I should have this working correctly tomorrow. It has already occurred to me that there’s a good chance I could simply design my way around this limitation in the current implementation, and that I shouldn’t let my urge to engineer solutions to problems that might not actually exist. But I also already told that objecting part of me to fuck right off, so I’m committed to a complete solution.

Leave a Reply

Your email address will not be published. Required fields are marked *