Random World Generation

Posted by Alex Larsen on Game Development See other posts from Game Development or by Alex Larsen
Published on 2012-10-19T10:35:13Z Indexed on 2012/10/19 11:27 UTC
Read the original article Hit count: 311

Filed under:
|
|
|

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?

© Game Development or respective owner

Related posts about XNA

Related posts about c#