Three Hundred :: Mechanic #164 Sites:     Webcomics   |   Three Hundred Mechanics   |   Three Hundred Prototypes
 Three Hundred
   - Index Page
   - About...
   - By Year

   - Comp-Grid
   - Procedural
   - Tactics
   - Tiny Crawl
   - Misc

PreviousMechanic #164Next

  Mechanic #164 - PGC: Border Quads
Posted: Oct 17, 2012

Create Zelda-like borders to your themed regions by using a buffer of rooms surrounding them.

  Border Quads

This entry is based on material published as a
Blind Mapmaker article on March 15, 2011.



Fig 164.1.

One of the virtues of ability-gated exploration games like Metroid or Zelda is that it strives to show the player the locked doors long before the player has the ability to open them. You see a cracked wall hours before you possess bombs to blow it up. This excites the player (what's behind that door?), makes the game feel less linear (I have bombs, now where did I see that cracked wall earlier?), and gives the player a bit of a puzzle as he tries to figure out what these things mean and how to use them.

One of the more exciting ways to dangle the future in front of the player is by using overlapping zone rooms. That is, rooms that are partially snow zone and partially desert zone, as seen above. It causes the player to see a new, exciting area and explore endlessly to figure out how to get there.

If you are trying to procedurally generate a Zelda-like game, figuring out a good way to create usable borders between your zones is fundamental. You need to know where to place obstacles the player can't pass and where to place obstacles the player can't pass YET. This entry is about creating these zone edges: border rooms that are two zones simultaneously.

  Basic Border Creation



Fig 164.2.

When creating you Zelda-like world, start by growing your first zone in some way. Once you have it, surrounded it by a thick line of border rooms, shown here in majestic magenta. By thick line, I mean that you want every empty space adjacent to your zone to be filled, even diagonally.



Fig 164.3.

Continue building zones in this manner. As long as you never intersect an existing border, and as long as you draw a thick border around the completed zone, you should never have two adjacent (even diagonally) rooms from different zones.



Fig 164.4.

Take every border cell and break it into four quadrants.



Fig 164.5.

Set the contents of each quadrant to the same zone as any room it is adjacent to (even diagonally). Due to the thick line, there won't be any situations where a quad touches more than one zone at a time. The contents of the quads depend ONLY on the non-border rooms it touches. Border rooms contribute nothing to its neighboring border rooms.

If you'll notice in this example, there are several places where quads contain nothing, as they neighbor only border cells and no zones. Also, in the purple zone, notice that U-shaped holes will be filled in completely.



Fig 164.6.

The final step is to erase the borders between any two quads that contain the same zone. Any borders the run between two quads of different zones is turned into a river. Though I use a river in this example, it can be any sort of barrier: mountains, cliffs, trees, lava, whatever. Keep in mind what abilities the player will have when moving from one zone to the next. For instance, a river will only be an obstacle up to the point the player can use a row boat.

In this example, for the empty quads, I just transformed them into more river. I guess that makes them lakes. You can do whatever you want with the empty quads, including extending zones further.



Fig 164.7.

Those U-shaped holes can be problematic if you are concerned about a particular flow through the zone. It can add a new room to the zone which may not be factored into previous decisions made about it. However, you can transform a border cell like this into a small lake with a river leading to it, preserving the "edginess" aspects of the room.



Fig 164.8.

You can use this technique to create rivers within a single zone. One possibility is to draw a river through a series of cells, then use the quadrant approach to control the edges. Or you can use it as a barrier between two identical zone types. When seen by the player, it will effectively be seen as a single zone, though it will have been created as two separate ones.

  Border Wobble



Fig 164.9.

Creating a border cell like this should work fine, and it should produce better results than hard borders between rooms. However, if you look at the Zelda games, you'll notice that in very few cases does the river cut exactly through the center of the room. In many cases, one side or the other is a bit larger.



Fig 164.10.

You can introduce a bit of border wobble to the mix by moving the lines defining the quadrants. You can move the middle point around and it'll create a little bit of variation. However, since the borders have to match up, this create a situation where once you define the horizontal line's position, it cannot be changed for any cells on that line.



Fig 164.11.

A simple solution to this is to shift the horizontal or vertical, but then treat the other borders as independently moveable. Instead of creating an L-shape with the borders, you can create a Z-shape. This keeps the cell broken into four pieces, instead of adding a fifth piece in the center if you were to move all four borders at the same time. Using this approach, you have a little more control over the border wobble and can likely correct or change borders easily.



Copyright 2007-2014 Sean Howard. All rights reserved.