logoalt Hacker News

Implementing Auto Tiling with Just 5 Tiles

40 pointsby todsacerdotilast Sunday at 1:37 AM5 commentsview on HN

Comments

zahlmantoday at 4:03 PM

There's a lot of explanation here but ultimately this is basically just the standard 16-tile set except assuming you can use rotations to deduplicate and don't need to allocate a tile for empty space. The latter makes sense for platformers (since your tiles likely represent objects that are supposed to be floating over some other background drawn another way) but not so much for, say, RPGs. (And the rotated tiles are often not great in RPGs, either.)

fredrikholmtoday at 1:32 PM

Tiling sprites is a wonderful example of something that starts off relatively simple and then explodes into all kinds of interesting headaches.

In the beginning, you're looking up a set of UVs in a table indexed by some mask value.

In the end, you're debugging errors where one off by one error cascades into strange realms of indexing the wrong (unloaded) chunk with coordinates rolling over to positions that make no sense, looking up neighbours that look one way yet you end up drawing something completely different.

The suggest solution is an elegant and relatively common approach to what would otherwise be a naive series of nested 40+ if statements consisting of much swearing and sprite editing.

bulgur999today at 1:39 PM

The low tile count simply comes from applying the dual grid approach popularized (if not invented) by Oskar Stålberg to a specific 2d perspective where tiles can be generated through rotations and/or flips.

show 1 reply
HugoDztoday at 2:56 PM

Very cool! Sprite Fusion maker here :)