0
\$\begingroup\$

Long story short. My levels tiles currently look like this:

currently

And i want them to look like this:

enter image description here

My levels are designed as 400x400 squares of proceduraly generated 0's and 1's, 0 representing dirt(walkable by player), 1 represeting stone(impenetrable). Game itself looks a lot like this.

At first, my method was to run another loop - after generating the world that replaced stone tiles, depending on directions of empty tiles were, with wall. The method doesn't work so bad up to the point where there are 1 wide walls sticking out, which are impossible for it to convert, check picture:

enter image description here

As you can see, in my method, the wall is an another texture, taking one tile itself. I can't replace air with walls, as that could possibly obstruct a passage. It basically fails every time there are 3 or more dirt tiles directly next to it.

This is the place at which i wondered if i chose the right method or if i should change the whole design for the walls, if so - to what? Should i create some textures for the 1-wides alone? Or maybe i shouldn't generate 1-wides at all? How do games generally deal with this?

I've looked for the answer to my problem, and haven't found it. Probably because it's hard for me to word it(sorry for messy post).

\$\endgroup\$
  • \$\begingroup\$ Can you make it more visually clear what is wrong with your approach? I don't get your problem. \$\endgroup\$ – Tinco Jul 20 '14 at 17:59
  • \$\begingroup\$ You should use an autotiling algorithm to display the walls. (See saltgames.com/2010/a-bitwise-method-for-applying-tilemaps) The example stand for a platformer, but i'm personnaly using it to display caves similar to what you want to achieve. \$\endgroup\$ – Khopa Jul 20 '14 at 21:15
  • \$\begingroup\$ @Tinco Yeah, not strange, it was very hard to word for me. Trying to make it simpler: I can't figure out the proper way to create walling around stone in a level. \$\endgroup\$ – Inquisition Jul 20 '14 at 23:05
  • \$\begingroup\$ @Khopa That is a brilliant link! Thank you, i will probably use it as game develops, answer provided below by Mario fits me fine for what i need now, but the site you provided answers my problem ultimately, thanks. \$\endgroup\$ – Inquisition Jul 20 '14 at 23:07
1
\$\begingroup\$

While it might not be ideal or the most performant option depending on your actual use case, you could just create a single "3d tile" that is actually bigger than your real tile (due to having the 3d part attached):

3D tile example

While the tile size would be 32 × 32 pixels, this tile image is actually 40 × 40 pixels big (the fake depth is 8 pixels in every direction).

When rendering, you just render the tiles from left to right, top to bottom, with the tile's delta (in this example 32 pixels).

For example, to render a "T", you'd render the tiles in the following order:

3D tiles examples

\$\endgroup\$
  • \$\begingroup\$ I really like your idea! That is brilliantly simplistic. I think i'll use it, because it really does all i need it to, for now. Thanks for the answer! \$\endgroup\$ – Inquisition Jul 20 '14 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.