Merge branch 'master' of https://git.koma.fail/grafika-beadando
This commit is contained in:
commit
4a1070a588
25
src/app.c
25
src/app.c
@ -252,17 +252,17 @@ float calc_frame_time(struct timespec *start, struct timespec *end)
|
|||||||
return elapsed_time;
|
return elapsed_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_generate_world(App *app, int x)
|
void app_generate_world(App *app, int a)
|
||||||
{
|
{
|
||||||
app->chunk_count = x*x;
|
app->chunk_count = a*a;
|
||||||
app->chunks = malloc(x*x*sizeof(Chunk));
|
app->chunks = malloc(a*a*sizeof(Chunk));
|
||||||
memset(app->chunks, 0, x*x*sizeof(Chunk));
|
memset(app->chunks, 0, a*a*sizeof(Chunk));
|
||||||
|
|
||||||
unsigned char ptable[512];
|
unsigned char ptable[512];
|
||||||
noise_init_ptable(ptable);
|
noise_init_ptable(ptable);
|
||||||
|
|
||||||
for (int i = 0; i < x; i++) {
|
for (int i = 0; i < a; i++) {
|
||||||
for (int j = 0; j < x; j++) {
|
for (int j = 0; j < a; j++) {
|
||||||
Chunk c;
|
Chunk c;
|
||||||
c.start_pos.x = i*CHUNK_MAX_X;
|
c.start_pos.x = i*CHUNK_MAX_X;
|
||||||
c.start_pos.y = j*CHUNK_MAX_Y;
|
c.start_pos.y = j*CHUNK_MAX_Y;
|
||||||
@ -270,9 +270,18 @@ void app_generate_world(App *app, int x)
|
|||||||
for (int x = 0; x < CHUNK_MAX_X; x++) {
|
for (int x = 0; x < CHUNK_MAX_X; x++) {
|
||||||
for (int y = 0; y < CHUNK_MAX_Y; y++) {
|
for (int y = 0; y < CHUNK_MAX_Y; y++) {
|
||||||
printf("x: %d y:%d noise: %f\n",
|
printf("x: %d y:%d noise: %f\n",
|
||||||
x, y, (noise_noise2(ptable, x*0.01, y*0.01) + 1) * 0.5 * 60);
|
x, y, (noise_noise2(ptable, x*0.005, y*0.005) + 1) * 0.5 * 60);
|
||||||
|
int mz = round((noise_noise2(ptable, x*0.005, y*0.005) + 1) * 0.5 * 60);
|
||||||
|
for (int z = 0; z < mz; z++)
|
||||||
|
c.blocks[x][y][z].type = BLOCKTYPE_STONE;
|
||||||
|
for (int z = mz; i < CHUNK_MAX_Z; i++)
|
||||||
|
c.blocks[x][y][z].type = BLOCKTYPE_AIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chunk_set_blocks_visibility(&c);
|
||||||
|
chunk_create_displayl(app, &c);
|
||||||
|
|
||||||
|
app->chunks[i+(j*a)] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user