Hi all!
I've made some system, where the placed tiles have several sprites, depends on neighbour tiles. So if two tiles of same type are near to each other, then it looks like they are placed together, no border between them. The spritesheet looks like https://github.com/ProjectET/Terraria-T ... r/TTGS.png (but not the same).
Can you please help me why the edge of the tile cannot be correct processed and the better sprite for this tile will be chosen?
Help with tiles and sprites
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Help with tiles and sprites
- Attachments
-
- ter-tiles-01.love
- (5.27 KiB) Downloaded 96 times
Re: Help with tiles and sprites
Ok, it was hardcoded limit in the cycle.
- Attachments
-
- ter-tiles-02.love
- License CC0 (no license)
- (5.9 KiB) Downloaded 99 times
Re: Help with tiles and sprites
Not sure what you're into, but for creating outlines around groups of identical tiles, I'd use a bitmapped system: 4 bits for the edges and 4 bits for the corners, total 8 bits. Not all combinations are valid, though: there are a total of 47 combinations of edges and corners, and where there's an edge, there are no corners. so it can be solved with a sparse table.
Here's the mapping of bits to corners and edges that I've chosen:
And here's the zoomed tileset with a gap between the tiles for better visibility:
A corner dot in the top left (for example) is necessary when:
- the tile on the top left of the current one is air;
- both the tile on the top and the tile on the left are ground.
Similarly for the rest.
An edge at the top (for example) is necessary when the current tile is ground and the tile on the top is air, and similarly for the rest.
Here's the mapping of bits to corners and edges that I've chosen:
And here's the zoomed tileset with a gap between the tiles for better visibility:
A corner dot in the top left (for example) is necessary when:
- the tile on the top left of the current one is air;
- both the tile on the top and the tile on the left are ground.
Similarly for the rest.
An edge at the top (for example) is necessary when the current tile is ground and the tile on the top is air, and similarly for the rest.
Re: Help with tiles and sprites
Sorry for the double post but 3 attachments are the maximum.
Here's the project.
The system can be trivially extended to curvededges corners, by changing the tileset.
Here's the project.
The system can be trivially extended to curved
Re: Help with tiles and sprites
Thanks! The format 0x00 is not very familiar for me, but I can understand the logic of it.
But how can I use several variants of the same type of tile? It's easy to make just one predefined, but several of them in the same scene is not so easy to me.
Re: Help with tiles and sprites
0x is the prefix that indicates that a number is in hexadecimal notation. I used hex because there are no binary literals, but hex to binary translation is trivial, so hex is the closest you can get to seeing the binary digits with reasonable readability.
Maybe using more bits. Bits 8 and 9 could be the bits of four variants. So, if the variant is a number from 0 to 3, add 0x100 if the variant is odd, and add 0x200 if the variant is >= 2. Or simply add the variant number times 0x100.
Or you could draw them in two layers: background and edges. The edges would follow the rules in my example while the backgrounds would have any variants you want. Or combining both, so you can have variants of edges too.
Re: Help with tiles and sprites
Actually, in LuaJIT there are, in the form of 0b11001.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: Help with tiles and sprites
Oops, thanks! Good to know.
Re: Help with tiles and sprites
It doesn't seem to be documented anywhere as far as I've seen, for some reason. I feel like LuaJIT's documentation is lacking in general. :/
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: Help with tiles and sprites
I've just checked and it seems that it only works in 2.1, which is not out of beta yet, so that may be a reason for it not to be documented.
In 2.0, 0bXXX literals don't work.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 5 guests