Thursday, 19 April 2012

Wall design

It's odd that I didn't think of this before, but I needed a design for walls that are used in level themes. It's a distinctive difference in the way I'm thinking game design now and then. So I wrote a design for walls which was a good idea, because now I finally know what types of walls I really need. Before this kind of thinking you just throw in some stuff without a clear plan how and where to use different types of walls. But now I have divided walls into 13 types which some are special walls like what nornokians made in Snow Top. They made stone walls from large, well-fitting granite stones. A remarkable skill that was lost with them.

Saturday, 14 April 2012

Corridor end tunneler

Rather than trying to do anything sophisticated I decided to use a special routine to tunnel away the walls in those dead end corridor situations. It's actually working nicely, because dead ends are present only in about 50% of levels and even then in 1-4 of rooms. The room is then marked as "broken" so nothing special is generated in that room and it may actually get a special room type where it looks like someone broke the room (broken items etc.)

What happens next with rooms is something I want to keep as secret, but in theory everything gets more complicated. I'm also going through the rest of level generation in hope to get each component present and ready for testing. I want to get level generation in a state where I can start to add special features without breaking the level structure.

Saturday, 7 April 2012

Dead end corridors

The first step to fix the dead end corridors was writing a routine that finds them. The rules are actually simple, you need a corridor, a room wall and no doors around a circular area to find a spot.

Also, the routine excludes walls with doors, but of course this doesn't work with round rooms, because the mask value for diagonal walls is different than the facing of main directions, because it has to be either one of main directions (walls on right and left are facing east and west, but they could also be facing north or south). Then again, the shape of room is also saved in the room data which can be detected and added to the algorithm. The spots are marked with lava tiles. Corridors running along with the wall get more than one hit, but they can be exluded by creating only one door or checking if the room is connected to that spot with good old flood fill check.

Testing connections

Fixed corridor corner fix, now it removes only the tile next to room wall. Then I started to test the level generator. Usually it works fine, but sometimes rooms and corridors have a bad alignment which makes impossible for them to connect.

Red circles show problem areas where connection has failed for various reasons. Sometimes there is another room blocking the way, sometimes corridors run at the round part of the round room. How to fix these? It's a good question. One possible way is check room connections, because rooms are objects and their data includes the number of connections (doors). So, a room with zero connections has obviously failed. Those rooms could then be connected with a special routine starting from a random room place and travelling from there with a special corridor routine (using path finder to find another corridor).

Friday, 6 April 2012

Corner fix failure

Fixed the flood fill which now correctly finds double doors to rooms by checking the connection with flood fill to make sure there is a connection per corridor and/or cavern. However the corner fix routine doesn't work that well.

I've painted red circles around the problem areas. The round room fix fails completely and that lower corridor is not connected at all. It just doesn't figure out how to create a clean entry through that wall. Also with that rectangular room the fix does work, but it's carving extra holes through corridor walls. A good way to approach bugs like this is use pen and paper to visualize the problem and create rules for the fix algorithm.

Flood fill failure

It's obvious that the flood fill search fails to detect nearby double doors.

As a debug measure I made the filler paint lava tiles where it did visit. The result was kind of interesting. Looks like it's quitting after couple of tiles. It's possible that the algorithm is confusing me, because for me even simple algorithms are hard to understand or visualize.

Tuesday, 3 April 2012

Corridor finder improvement

I think the bug in corridor corner fix was caused by a wrong call order of routines which made all corridor walls look like corners! Simply calling transform terrain first seems to correct most bugs in that area, as this new screenshot shows:

Still the problem is how to connect rooms to caverns (thick corridor here). It could be nice to avoid too many connections so it means checking cavern areas with flood fill to see if they are connected. Tiles not connected would be listed so you would need to go through them and check for room walls or nearby corridors to join them in the level structure from one (or more) points to avoid hacking away all room walls (if there are a lot of cavern areas around rooms).

Monday, 2 April 2012

Round room corners

The corner fix routine fails when trying to find a door place in round rooms:

One solution would be allowing entrances to round rooms only in four main directions, because there is a straight wall section on each side of the room. Another solution would add extra walls to room to fix broken walls. It might be even easier routine to do, because the areas to check are connected to doors so it would be simple to spot the areas by going through the door list and checking tiles (or double doors) around them.