Top-down 2d Tile game - how to generate wall tiles?

Started by
9 comments, last by Sporniket 9 years, 8 months ago

I am working on a simple 2D top down tile based game where a tile is either "floor" or "wall." A good example of what I want is the oldschool Alien Assault:

AlienAssault2_zps88115aa9.jpg

Now my question is - how do I create the wall tiles? If I was just to hand-draw these then it would mean 256 different wall tiles (since each tile is surrounded by 8 tiles that can be wall or floor, so 2^8 = 256). Even if I do some mirroring/rotating, it's still seems like an annoying amount of tiles (especially laying those out onto a tilesheet to fit some auto-matching algorithm).

Is there a better way of doing this, or is that pretty much how most 2D games do it?

One other idea I had was to (just for rendering) subdivide each tile into 4 and treat each corner separately. Since you always know the corner will have at least two surrounding walls you only need 4 variants per each corner, meaning 16 images total:

2dtilesv2_zps58e0b107.jpg

Looking at RPG maker tilesets I am guessing this is how they do walls, as all you need is this:

rpgmaker_tiles_zps8aff56ef.jpg

To create something like this:

dungeon_test_1_by_nicnubill-d6pzrmn_zps4

The only CON here is that, since the walls would be using a lot more smaller pieces, they could get easily very repetitive, unless I introduce few variants for each of the pieces and randomize it?

Any input from the more experienced is appreciated.

(also, I did try searching but oddly having a hard time finding tutorials for this topic. Ho hum!)\

EDIT: actually here is a the RPGMaker autotile explanation, which is basically what I jsut figured out above lol: http://blog.rpgmakerweb.com/tutorials/anatomy-of-an-autotile/

Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
Advertisement

each tile is surrounded by 8 tiles that can be wall or floor

That's the number of directions, not the number of required tiles. I think there are only about 20-30 basic tiles, something based on your approach below that. The primary tile size is the size of a bare floor without walls. The walls are separate from the floor and are rendered adjacent to floor tiles. There's a bare floor tile, north/south/east/west walls, corner tiles for NE/SW/SE/NW outside corners, and NE/SW/SE/NW inside corners. Looks like the wall and corner tiles are half- or quarter-size, and you need quarter-size wall tiles for the other half of inside corner tiles. If you flip wall tiles horizontally and vertically (just tex coord changes) you can get away with a floor tile, an inside corner, an outside corner and a half-wall tile.

There are some wall tiles with semi-circles and maybe a door tile? There's also what appears to be some sort of pattern laid over the top of some sections (the floor area where the green guys are near the top), possibly an alpha texture.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

256 tiles? I don't think so...

How_many.png

None of those tiles really take into account their neighboring tiles, with only a few exceptions (the ironbar/doorway things, and that grate). Those exceptions could easily be handled by having two or more layers of tiles.

According to Servant's breakdown, the basic tiles are: 1 floor tile, 8 surrounding wall tiles and 4 inside corner tiles. Add more as needed for variation.

Also note that those tiles are using pseudo-perspective.

Thanks for the responses.

Yea the tiles used in my example seem a bit simplified with some restrictions (like not having very narrow walls). But if you wanted to have no restrictions and wanted to cover every possibility, then you need to account for potential wall-or-floor on any of the 8 adjacent tiles (otherwise it would not "link" correctly and you'd get artifacts). And since which means 2^8 possibilities. Or maybe my math-fu is failing me? H

The problem becomes more pronounced with more tight environments (i.e. rooms/corridors with lots of turns separated by just one or two walls max). Like here:

complex-tiles_zps18c769d8.jpg

Merely "corner in + corner out + wall" wouldn't cut it. I do realize a lot of those are rotated/flipped versions but I am talking about the actual # of tiles required without mirroring/rotating/layering.

Wouldn't mirroring/rotating/layering lead to potential glitches? You can't flip/rotate if unless your walls are symmetrical. And you can't layer some combinations, like side walls that would intersect as that would make them not connect properly.

Hmm I think I will go with the Autotile solution from RPG gamer for now, as it seems to be the most dynamic.

Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...

Can't you make the graphical tiles smaller? That's what I did in a tile-based 3D game I was working on, all tiles were actually constructed from 4 different pieces.

Derp

This article is about transitioning terrain tiles:

http://www.gamedev.net/page/resources/_/technical/game-programming/tilemap-based-game-techniques-handling-terrai-r934

And this forum post explores it a little further:

http://www.gamedev.net/topic/606520-tile-transitions/

I think they'll shed some light on your problem.

- Eck

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

Thanks for the responses.

Yea the tiles used in my example seem a bit simplified with some restrictions (like not having very narrow walls). But if you wanted to have no restrictions and wanted to cover every possibility, then you need to account for potential wall-or-floor on any of the 8 adjacent tiles (otherwise it would not "link" correctly and you'd get artifacts). And since which means 2^8 possibilities. Or maybe my math-fu is failing me? H

The problem becomes more pronounced with more tight environments (i.e. rooms/corridors with lots of turns separated by just one or two walls max). Like here:

complex-tiles_zps18c769d8.jpg

Merely "corner in + corner out + wall" wouldn't cut it. I do realize a lot of those are rotated/flipped versions but I am talking about the actual # of tiles required without mirroring/rotating/layering.

Wouldn't mirroring/rotating/layering lead to potential glitches? You can't flip/rotate if unless your walls are symmetrical. And you can't layer some combinations, like side walls that would intersect as that would make them not connect properly.

Hmm I think I will go with the Autotile solution from RPG gamer for now, as it seems to be the most dynamic.


One rather simple option is to just use multiple tiles per grid position, that way you only need 2 basic wall tiles(wall/corner) and can rotate and layer them on top of eachother for grid positions with multiple walls.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Your basic pieces, which can be assembled on a transparent background to make the required 256 exterior tiles, are: 4 corners with no adjacent edges (the round ones in the mockup), 8 corners with one edge, 4 corners with two edges. (There's also the empty corner, with no graphics.)

Assembly can take place dynamically on a half-step grid (where tile corners are 1 corner, two side midpoints and one center of an original grid space).

Depending on your style, the 16 corner graphics can be collapsed to only 3 (not shaded) or at least used as a reference for each other. Adding variations doesn't seem out of the question.

Omae Wa Mou Shindeiru

You should have told us what language or program you was using before asking this question. Congratz on figuring it out thought.

This topic is closed to new replies.

Advertisement