2017/09/21

DooM fangame: Progress Report #7 - Tile-Based Headaches

So it's been a while since I last updated, and, sadly, I got no screenies today.

I'm working on the map rendering code, having to rework a lot of it to make it function properly.

The main issue has been using bitmasks to map situations where an individual tile has different types of neighboring tiles, like say, a floor tile sitting between a chasm and a wall.

After much headache and lots and lots of calculations, I had a revelation: What if I split my 32x32 tiles into four 16x16 tiles? That way they'll be guaranteed to only have, at most, two different types of neighboring tiles!

One of the many pages...

I, of course, immediately slapped myself after that epiphany, because that's a very common technique I should've been using since the beginning instead of my usual trying to re-invent the wheel.


That settled, I also decided to turn the rendering process on its head, as, in those screenies in previous posts, what I'm doing is calculating the bitmasks for rendering each frame, for each tile, which made locating the points where the calculations were failing quite a hassle.

Now I've reworked it so I pre-generate a map with the actual texture indices for the tiles at map load, so there are no calculations done during rendering.

Currently, I'm having difficulty defining a proper syntax for the  tile mappings (that is, the definition of which part of the texture to use based on the surrounding tiles), given that I have to consider different tile types, plus some exceptions.

But I feel like I can give it all a good push this weekend. We'll see.


No comments:

Post a Comment