Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Koobazaur   Members   -  Reputation: 691

Like
0Likes
Like

Posted 19 July 2014 - 12:54 AM

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/


Edited by Koobazaur, 19 July 2014 - 12:58 AM.

Postmortem: one must die -  Political narrative-adventure game playing an Agent of Death who must take ONE life that could change the fate of a conflict-torn Nation

 

Check out my DevBlog for news on the next title!


Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 4889

Like
1Likes
Like

Posted 19 July 2014 - 07:23 AM


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.


Edited by Buckeye, 19 July 2014 - 07:29 AM.

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


#3 Servant of the Lord   Crossbones+   -  Reputation: 19499

Like
9Likes
Like

Posted 19 July 2014 - 08:07 PM

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.


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#4 Kryzon   Prime Members   -  Reputation: 3031

Like
0Likes
Like

Posted 20 July 2014 - 04:35 PM

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.

#5 Koobazaur   Members   -  Reputation: 691

Like
0Likes
Like

Posted 29 July 2014 - 09:23 PM

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. 


Edited by Koobazaur, 29 July 2014 - 09:48 PM.

Postmortem: one must die -  Political narrative-adventure game playing an Agent of Death who must take ONE life that could change the fate of a conflict-torn Nation

 

Check out my DevBlog for news on the next title!


#6 Sponji   Members   -  Reputation: 1246

Like
0Likes
Like

Posted 30 July 2014 - 04:26 AM

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

#7 Eck   Members   -  Reputation: 2719

Like
5Likes
Like

Posted 30 July 2014 - 10:35 AM

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



#8 SimonForsman   Crossbones+   -  Reputation: 6106

Like
0Likes
Like

Posted 30 July 2014 - 11:00 AM

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.

Edited by SimonForsman, 30 July 2014 - 11:02 AM.

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!

#9 LorenzoGatti   Crossbones+   -  Reputation: 2688

Like
0Likes
Like

Posted 01 August 2014 - 02:29 AM

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.


Produci, consuma, crepa

#10 LAURENT*   Members   -  Reputation: 217

Like
-2Likes
Like

Posted 01 August 2014 - 02:39 PM

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



#11 Sporniket   Members   -  Reputation: 344

Like
0Likes
Like

Posted 07 August 2014 - 06:31 AM

Seeing your screenshot, I sense that you should separate the model of your level from the rendering :

 

The model is a matrix of cells that are "floor" and "empty" and match the red grid on your screenshot. We don't need walls in this model : the player can go to a neighbour cell (8 direction) only if this neighbour cell is "floor".

 

On the other hand, the rendering of your maze use a smaller grid so that it can use a tileset like the one you found. Here I would say that one cell is drawn using 4 tiles. The tiles array is preprocessed to compute where to put a wall.


Space Zig-Zag, a casual game of skill for Android by Sporniket-Studio.com





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS