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

Back to Vinland.

I'm going back to my real time tactics project, Vinland 1936.
While working on the other project I overcame the problems which were stopping me from saving/loading the game and also cleaned up the base code a lot.

After a few weeks I'm getting near the the state I was in before.


Infantry are back to their previous state, and vehicles are running OK.
This time I'm going to push ahead with mocking up the combat system though before I work any more on the vehicle builder or graphical aspects of the game.

Map screen designs

I've been working some more on the map window. Right now you can only see the base, it doesn't show items, enemies or even doors on the map yet. These would be decals.


In the top window you can see the modified result of last night's tile based map. It looks good but there are some visual artifacts related to the problems I encountered yesterday, and as well it takes much more code and time to calculate.

The second window uses a cheap trick to fake an beveled look from a smoothed version of the 32x32 map. It uses black to mask unexplored areas.

Finally the third version is meant to look like a had drawn map. I'm using a cross hatching texture to distort it and unexplored areas are shown as blank map paper.

There's going to be a mechanic in game where you need to use some paper every level in order to activate the map for that level. From there it will fill it in automatically. Paper will be pretty rare so it might be worth keeping it safe for the more complex level…

Infantry combat and entering buildings.

I've been working a lot on the game recently and I've nearly rebuilt it to the level it was before. Past that maybe, since now I have the beginning of a working combat system and the ability to save and load the game.


Infantry can now occupy a building. It's quite an abstract representation, since they stay at the door and turn invisible. But they can then fire from one of the windows and take damage from shots at the windows too. I think I've set it up well so that when building damage and destruction is working then the system should continue to work.

For combat I tried some new ideas, but they didn't work out that well. It seems that it's important that viewing range should be further than shooting range. Now shooting range is pegged at 18 units of distance, while viewing range can extend out past that.

In the above image one unit has an officer, so has further viewing range. The other can only see as far as they can shoot, a dangerous situation since the en…