Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
terrain generator
// Generate a random offset
float offset = ((float) rand() / (100000));
this->width = width;
this->height = height;
// Initilize the array
this->blockArray = new Block**[width];
for(int i = 0; i < width; ++i)
{
this->blockArray[i] = new Block*[height];
}
// Now generate terrain
for(int x = 0; x < width; x++)
{
float ph = SimplexNoise::noise((float)x + offset);
std::cout << ph << std::endl;
int bh = ph * height;
for(int y = 0; y < height; y++)
{
if(y > bh)
{
this->blockArray[x][y] = new Block(1);
}else
{
this->blockArray[x][y] = new Block(0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.