Skip to main content

Tileset methods.

If you're making a game in 3d there are a number of ways to handle tilesets and tiles.
The easiest but least flexible is to handle each single tile as a tile and just place them with no regard for the adjacent tiles. Walls in this case are made of 1x1 pillars of wall material.

This is great, but it doesn't allow for very varied tile sets. It also leads to very repetitive, bland looking dungeons. You could make things a little more random by using multiple kinds of wall and floor tiles, randomly placed, or use an algorithm when placing them.

Here's a look at Eye of the beholder on the gameboy advance which uses that method, though it's actually 2d isometric, not 3d:

Very blocky tiles.

Another method is to use tiles which are bigger than 1x1. In the case of my first attempts, I used a 10x10 tileset. This allows some very interesting shaped rooms such as circles and some kinds of irregular tiles such as caves. We could call these prefabs or kits.

My first tileset for the game.

This requires a quite complex placement method. You have to check the tile type and then check the tile types of the four tiles to the north, east, south and west.

[[0,1],[1,0],[0,-1],[-1,0]]
You can use a search array like this.

Then you place parts of the tile which will mix or transition with those types. Combinations can be either transition (the two tiles are compatible floor tiles) doorway (maybe not actually a real doorway, but a special bridging transition) or wall (solid rock).


For example if the current tile you are placing is a floor tile, and the northern tile is a wall tile, you have to place the northern part of the tile with the following code:

north-floor-wall

We can name the objects like this:

NFW

This works really well and gives really nice transitions, but the way of splitting the tile, from the four corners in to an "X" shape means we need to have pillars of rock at each corner, unless the floor tiles fill the whole of the 10x10 space (not a good idea). It also makes any kind of naturalistic tile set very ugly. Here's an abandoned "cave" type tile set:



Notice the large open areas are broken up by the repeating "pillars" at the corner of each tile. This is the problem with this technique, it produces nice corridors but horrible open spaces.


Another method, which I'll be using from now on uses single tiles instead of a set of 4 split into north south east and west.

You can see that they look like the corners of the room, just 1/4 of a room like we used above, but actually they are full 4x4 sized rooms, but offset by 50% to the north east (it looks like the corner of a room because I've made the walls cover only 25% of the room instead of 50%). Instead of the 4 NESW tiles above, we need 16 for each type of feature, but we can cut this down a lot by using rules which disallow certain types of tile placement. For example note that doors can only be placed in the NESW part of the tile, not in the corner. It's not actually all that difficult to make all the variations, since most are just modifications of each other, either rotated or mirrored.

How does it work? Well, for each tile we take the current tile, and its neighbors in order:

Self, North, Northeast, East. 
[[0,0],[0,1],[1,1],[1,0]] 

This returns a string such as WWDF (Wall, Wall, Door, Floor). We can use this string to place a named tile.

The important thing though is that now we can have large rooms with no pillars. We can also have better textures, since they don't have to be tiled diagonally and don't have to match up on those unpleasant "X" edges.

We can still have nice transitions, and doors but now we can have large rooms, and more natural looking caves.

The final modeled and textured tileset will look far superior to the current one. I'm also revisiting my dungeon generation script to make it quicker to build compact, well filled maps, and to be more versatile when placing entrances, exits, locked doors, themed monsters, themed tilesets and other stuff. I'll be using BSP trees to delineate some "rooms" like a 12X12 square or a 5X10 rectangle, and then I'll place a pregenerated "room array" in that space.

The pregenerated arrays will be drawn by hand using the helper utility you can see in the last picture above (with the blue wall tiles and yellow floor tiles). Then they will be saved in to a dictionary. The arrays can be flipped or rotated by 90 degree increments. There will be a lot of them so you're unlikely to run in to the same one too many times. They can include groups of rooms, prison cell layouts, underground churches or temples, mazes and labyrinths and all sorts of different kinds of areas. I'll also be able to mark tiles as stairs up/ down, or other features such as dining rooms or libraries. Later I'll add code for placing specific monsters, NPCs, treasure or furniture on different squares. Maybe even cut scene cues, special event triggers or at least message log generators. This will also allow me to make some special areas such as boss fights, treasure rooms, trapped mazes and even puzzles eventually.

This means the end result will be a mix of random, procedurally generated content and designed areas. Some parts will be simple rooms with themed monster or furniture spawns:

You enter a room, there are two doors on the far wall. A line of pillars run down the center of the room. A pit is in the corner. There are several cocoons hanging from the ceiling,  a pile of spider eggs pulsates on top of a large rock. Three giant spiders peer at you from the darkness.

Other areas may be more complex:

There is an altar in the central room. Other rooms split off from this one to the North, South and East. As soon as you enter, the door slams shut behind you. There is an evil priest at the altar and several cultists around him. There are a couple of levers near the altar jutting from the floor. A woman is chained to the altar, she look like the daughter of the innkeeper who you are searching for. A big pentagram is inked on the floor, within the pentagram a dark shape writhes, half summoned.

Anyway, that's all for the future. For now it'll just be plain room arrays that will have "feature" tiles which can spawn mobs of monster or arrays of furniture.

Comments

Popular posts from this blog

Advice needed on tilesets...

I need some advice on which is the best way to handle building the dungeon. Right now I'm using prefabs for my dungeon, they have a north south east and west section for each "room": The basic tileset. This has several advantages, and also several disadvantages. Firstly I can have curved rooms, I can have tunnels and other interesting shapes. The tilesets can look quite nice with a little work. On the other hand I can't easily get the navigation data before building the map and once the map has been built I can't make changes to the layout, like having active pit traps or believable secret doors. Although the rooms are interesting, they are quite repetitive, and it takes a lot of effort to make even a few different variations. Also rooms are constrained to one size. A newer version of the tileset with a lot of variant parts for making more interesting rooms. To create a tile set is a real headache too. Planning how to lay out the UVs, trying to cra...

Upstairs / Downstairs.

I've decided to make my prefabs multilevel. Later this should allow me to add pit traps and other great stuff. It also makes it easier to line up stairs so that you can exit them on the same co-ordinates where you entered them. The prefab editor is pretty much finished, it just needs some code for loading up prefabs from a saved dictionary, so that they can be checked or edited. The entries will need to be forwards compatible, so I'll be loading each tile and then translating the indexes to a new array, that way if I add extra indexes or extra info (like traps or puzzles) I'll be able to update existing prefabs to work with the new standard. Click for a video.

Video Diary 8

Things are moving along well, there's been a lot of progress on the action manager side of things. Actions have finally moved to the UI, so you can initiate actions by clicking the appropriate button. I've set up some dummy actions to show what happens visually when actions are taken, but the actual dice rolls and such are yet to be integrated. The UI objects are also being added, though some are non functional or empty at the moment. Click on the image to see this week's development video. Every time I add something big I also add about a dozen small things. Like the selection box visualization. Previously this was using render.drawline, and old fashioned Blender function which can be impossible to see at certain resolutions, or at certain frequencies. I replaced it with a function that adds planes of the right size and scale in the right location. I also made all characters a little bigger. I still need to do some work with vectors and final target locations t...