generation update
This commit is contained in:
parent
c38eeaa57d
commit
0aa891f35f
BIN
res/block.png
BIN
res/block.png
Binary file not shown.
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 258 KiB |
@ -70,7 +70,7 @@ int initialize_assets(Assets* assets) {
|
||||
|
||||
// All in-game definitions (blocks, items, etc..)
|
||||
void setup_definitions() {
|
||||
// AIR
|
||||
// AIR 0
|
||||
Block* block = new Block(0,0);
|
||||
block->drawGroup = 1;
|
||||
block->lightPassing = true;
|
||||
@ -79,48 +79,48 @@ void setup_definitions() {
|
||||
block->selectable = false;
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// STONE
|
||||
// DIRT 1
|
||||
block = new Block(1,2);
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// GRASS
|
||||
// GRASS 2
|
||||
block = new Block(2,4);
|
||||
block->textureFaces[2] = 2;
|
||||
block->textureFaces[3] = 1;
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// LAMP
|
||||
// LAMP 3
|
||||
block = new Block(3,3);
|
||||
block->emission[0] = 15;
|
||||
block->emission[1] = 14;
|
||||
block->emission[2] = 13;
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// GLASS
|
||||
// GLASS 4
|
||||
block = new Block(4,5);
|
||||
block->drawGroup = 2;
|
||||
block->lightPassing = true;
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// PLANKS
|
||||
// PLANKS 5
|
||||
block = new Block(5,6);
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// WOOD
|
||||
// WOOD 6
|
||||
block = new Block(6,7);
|
||||
block->textureFaces[2] = 8;
|
||||
block->textureFaces[3] = 8;
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// LEAVES
|
||||
// LEAVES 7
|
||||
block = new Block(7,9);
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// ACTUAL STONE
|
||||
// STONE 8
|
||||
block = new Block(8,10);
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// WATER
|
||||
// WATER 9
|
||||
block = new Block(9,11);
|
||||
block->drawGroup = 4;
|
||||
block->lightPassing = true;
|
||||
@ -128,6 +128,15 @@ void setup_definitions() {
|
||||
block->obstacle = false;
|
||||
block->selectable = false;
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// SEND 10
|
||||
block = new Block(10,12);
|
||||
Block::blocks[block->id] = block;
|
||||
|
||||
// BEDROCK 11
|
||||
block = new Block(11,13);
|
||||
block->selectable = false;
|
||||
Block::blocks[block->id] = block;
|
||||
}
|
||||
#endif // DECLARATIONS_H
|
||||
|
||||
|
||||
@ -34,7 +34,8 @@ float calc_height(fnl_state *noise, int real_x, int real_z){
|
||||
height += fnlGetNoise3D(noise, real_x*0.05f*s*32,real_z*0.05f*s*32, 0.0f)*0.25f;
|
||||
height += fnlGetNoise3D(noise, real_x*0.1f*s*32,real_z*0.1f*s*32, 0.0f)*0.225f;
|
||||
height += fnlGetNoise3D(noise, real_x*0.2f*s*32,real_z*0.2f*s*32, 0.0f)*0.125f;
|
||||
height += fnlGetNoise3D(noise, real_x*0.4f*s*32,real_z*0.4f*s*32, 0.0f)*0.125f*0.5F;
|
||||
height += fnlGetNoise3D(noise, real_x*0.4f*s*32,real_z*0.4f*s*32, 0.0f)*0.0625f;
|
||||
// height += fnlGetNoise3D(noise, real_x*s*32,real_z*s*32, 0.0f)*0.03f;
|
||||
height = height * 0.5f + 0.5f;
|
||||
height *= height;
|
||||
height *= (140.0f)*0.12f/s;
|
||||
@ -71,7 +72,7 @@ int generate_tree(fnl_state *noise, PseudoRandom* random, const float* heights,
|
||||
int centerX = tileX * tileSize + tileSize/2 + randomX;
|
||||
int centerY = tileY * tileSize + tileSize/2 + randomZ;
|
||||
int height = (int)calc_height_faster(noise, centerX, centerY);
|
||||
if (height < 55)
|
||||
if ((height < 57) || (fnlGetNoise3D(noise, real_x*0.025f,real_z*0.025f, 0.0f)*0.5f > 0.5))
|
||||
return 0;
|
||||
int lx = real_x - centerX;
|
||||
int radius = random->rand() % 4 + 3;
|
||||
@ -102,20 +103,19 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cy, int cz){
|
||||
}
|
||||
|
||||
for (int z = 0; z < CHUNK_D; z++){
|
||||
int real_z = z + cz * CHUNK_D;
|
||||
for (int x = 0; x < CHUNK_W; x++){
|
||||
int real_x = x + cx * CHUNK_W;
|
||||
int real_z = z + cz * CHUNK_D;
|
||||
float height = heights[z*CHUNK_W+x];
|
||||
|
||||
for (int y = 0; y < CHUNK_H; y++){
|
||||
int real_y = y + cy * CHUNK_H;
|
||||
int id = real_y < 55 ? 9 : 0;
|
||||
if (real_y == (int)height)
|
||||
if ((real_y == (int)height) && (54 < real_y))
|
||||
id = 2;
|
||||
else if (real_y < height){
|
||||
if (real_y < height-6)
|
||||
else if (real_y < (height - 6)){
|
||||
id = 8;
|
||||
else
|
||||
} else if (real_y < height){
|
||||
id = 1;
|
||||
} else {
|
||||
int tree = generate_tree(&noise, &random, heights, real_x, real_y, real_z, 16);
|
||||
@ -127,11 +127,21 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cy, int cz){
|
||||
id = tree;
|
||||
}
|
||||
}
|
||||
// if ((real_y < height) && (57 > height) && (height > 51) && ((int)height == real_y)){
|
||||
// id = 10;
|
||||
// }
|
||||
|
||||
// if ( ((height - (1 - 0.1 * pow(height - 55, 4))) < real_y) && (real_y < height)){
|
||||
// id = 10;
|
||||
// }
|
||||
|
||||
if ( ((height - (1.5 - 0.2 * pow(height - 55, 4))) < real_y) && (real_y < height)){
|
||||
id = 10;
|
||||
}
|
||||
if (real_y <= 2)
|
||||
id = 2;
|
||||
id = 11;
|
||||
voxels[(y * CHUNK_D + z) * CHUNK_W + x].id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user