301 Days

A year of gamedev experiments.

Day 3 - Some Abysmal Visuals

| Comments

So I gave in to nostalgia and made more of the textures green-text-on-black:

Old school terminal aesthetic

I think I’ll leave the base layer like that until I can take the time to make something nice. In the game, each cell is supposed to be 10 feet by 10 feet, but the Z values in the map are in single feet instead of tens of feet. So let’s fix the position and scale of the blocks:

1
Vector3 position = new Vector3((-1f) * cells[v].X, (-1f) * cells[v].Y, 0.1f * cells[v].Z);

Make the cell prefab only one foot thick

So now the cells are one foot thick and positioned appropriately to the map scale. But that makes it really difficult to see into the dungeon:

Extreme angle to try to see dungeon under surface layer

What we need is some sort of Z-filter so we can choose what is the highest layer we want to see. Let’s keep track of the Z planes in the MapManager:

1
2
public int[] zPlanes; // Array of elevations of Z planes, as copied from Map
public int currentZTopIdx; // Index into zPlanes for highest elevation currently visible
1
2
3
ourMap.ZPlanes.Sort();
zPlanes = ourMap.ZPlanes.ToArray();
currentZTopIdx = zPlanes.Length - 1;

Then add a method to cycle up or down through the layers, turning off the renderers on any block above the current layer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public void CycleZ(bool up) {
    currentZTopIdx += (up ? 1 : -1);
    if (currentZTopIdx < 0) currentZTopIdx = 0;
    if (currentZTopIdx >= zPlanes.Length) currentZTopIdx = zPlanes.Length - 1;
    Renderer currBlockRend;
    foreach (Vector3 v in cell_transforms.Keys) {
        currBlockRend = cell_transforms[v].GetComponent<Renderer>();
        if (v.z > zPlanes[currentZTopIdx]) {
            currBlockRend.enabled = false;
        } else {
            currBlockRend.enabled = true;
        }
    }
}

Then over in the GUIManager let’s let the A and Z keys cycle the layer up and down, and display the current top layer:

1
2
3
4
5
6
7
8
void Update () {
    if (Input.GetKeyDown (KeyCode.Z)) {
        map_manager.CycleZ(false);
    }
    if (Input.GetKeyDown (KeyCode.A)) {
        map_manager.CycleZ(true);
    }
}
1
GUI.Box (new Rect (0,Screen.height - 50,100,50), "Z top\n" + map_manager.zPlanes[map_manager.currentZTopIdx]);

Despite the fact that we’re touching the renderer on every block, it works pretty fast: Peeling back the layers

Now we’re ready to try watching a live game world.

Day 3 code

Useful tool: ScreenToGif

Comments