Map Design - nt314p/Zork GitHub Wiki

Map Representation

Because our map is a 3D array of Places, it can store both Room objects and Side objects (which include its subclasses: Wall, Door, and Opening).

Here is a 2D representation of our map. It is a single floor or layer in our map.

In this image, all rooms are blue and all sides are green. Empty places are white. Each Place (Room or Side in this case) can be accessed using a ordered pair, or xy coordinate. Notice how rooms only exist on a double "half" value and sides exist with one "whole" value and one "half" value. The image shows a room at (1.5, 0.5) and a side at (2.5, 2.0). Empty or null places exist on double "whole" values, and mean nothing in our map representation. Notice how each room shares some sides with another room. This simplifies the map state. When a side is updated, rooms that have the side receive the update as well. In 3D, which is actually how our map is stored, a z dimension is added.

Again, the green cubes represent sides and the blue cubes represent rooms. Notice now that rooms now have ceilings and floors. This is intentional; not only can this 3D representation support multilevel maps, but we can control the ceilings and floors as well. The bottom layer is z = 0.0, and each cube layer up adds another 0.5 to the z coordinate.