summary refs log tree commit diff
path: root/src/World/Generator.cpp
blob: 5b8b9b5d94979f309b184777357437a892edf6bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "Generator.hpp"

namespace MC {

Chunk Generator::generate(uint32_t _x, uint32_t _y) {
    Chunk chunk;

    for (int y = 0; y < CHUNK_HEIGHT; y++) {
        BlockType type = BlockType::Air;
        if (y < CHUNK_HEIGHT / 2) {
            type = BlockType::Dirt;
        } else if (y == CHUNK_HEIGHT / 2) {
            type = BlockType::Grass;
        }

        for (int x = 0; x < CHUNK_WIDTH; x++) {
            for (int z = 0; z < CHUNK_WIDTH; z++) {
                chunk.set(x, y, z, type);
            }
        }
    }

    return chunk;
}

}