Generate next chunk with perlin noise

I'm actually trying to generate a level with procedural generation using perlin noise. So one chunk has a size of 30x30, it's a float 2d array and at first I'm filling it with values between 0 and 1. Next step is to calculate 7 octaves and merge them. In the end I normalize the values. All this works quiet well if I only want to create one chunk but how can I create one more chunk beside my first so that they fit together smoothly?

Just set it up so your chunk has an origin, and add that to the values you're using to sample the perlin noise. i.e

void GenerateChunk(Chunk chunk, Perlin noise)
{
for(int x = 0; x < chunk.width; x++)
{
for(int y = 0; y < chunk.height; y++)
{
chunk.value[x][y] = noise.Generate(x + chunk.origin.x, y + chunk.origin.y);
}
}
}


Now you've got a chunk at (0,0), one at (30, 0), one at (0, 30) and so on.

Expanding on the previous answer what you need is a concept of global coordinates. Every cell in the world has a globally unique coordinate which is used to generate that cell's random value. The cells themselves are stored in chunks in chunk local coordinates though, so you need a way to address each cell by chunk and offset. The spatially coherent properties of Perlin/Simplex noise then takes care of the rest.

I have some basic code examples for chunk addressing and "water-line" random generation in this blog post. Hopefully I will have posts on a more fleshed-out map generation system soon.