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:
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.
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.
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:
We can name the objects like this:
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:
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.
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
Post a Comment