#include "common/world/World.h" #include "gaming-core/utils/Random.h" #include "common/world/HighMap.h" World::World(const BlockRegistry& blockRegistry) : blockRegistry(blockRegistry) { Block air = blockRegistry.getBlock("air"); Block stone = blockRegistry.getBlock("stone"); HighMap map; for(int x = 0; x < WORLD_SIZE; x++) { for(int z = 0; z < WORLD_SIZE; z++) { int height = map.getHeight(x, z, WORLD_SIZE); for(int y = 0; y < height; y++) { setBlock(x, y, z, stone); } for(int y = height; y < WORLD_SIZE; y++) { setBlock(x, y, z, air); } } } } void World::setBlock(int x, int y, int z, const Block& block) { blocks[x & BITMASK][y & BITMASK][z & BITMASK] = block.getId(); } const Block& World::getBlock(int x, int y, int z) const { return blockRegistry.getBlock(blocks[x & BITMASK][y & BITMASK][z & BITMASK]); }