Random World Generation
- by Alex Larsen
I'm making a game like minecraft (although a different idea) but I need a random world generator for a 1024 block wide and 256 block tall map. Basically so far I have a multidimensional array for each layer of blocks (a total of 262,114 blocks).
This is the code I have now:
Block[,] BlocksInMap = new Block[1024, 256];
public bool IsWorldGenerated = false;
Random r = new Random();
private void RunThread()
{
for (int BH = 0; BH <= 256; BH++)
{
for (int BW = 0; BW <= 1024; BW++)
{
Block b = new Block();
if (BH >= 192)
{
}
BlocksInMap[BW, BH] = b;
}
}
IsWorldGenerated = true;
}
public void GenWorld()
{
new Thread(new ThreadStart(RunThread)).Start();
}
I want to make tunnels and water but the way blocks are set is like this:
Block MyBlock = new Block();
MyBlock.BlockType = Block.BlockTypes.Air;
How would I manage to connect blocks so the land is not a bunch of floating dirt and stone?