Skip to content

Commit

Permalink
changed worldgen a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
segfaultdev committed May 10, 2022
1 parent 8d23ebb commit 7200bfd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

// tree 0.11 - the ALIVE update:
// - make grass not grow that long
// - make fire spread a lil bit more downwards
// -
// - use "tile" instead of "getTile()" in immense if-else blob

// tree 0.12:
Expand Down
11 changes: 10 additions & 1 deletion tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void del_tile(int x, int y) {

void world_gen(void) {
for (int i = 0; i < WIDTH; i++) {
int height = (int)((noise_1(i / 59.7f) * 0.3f + noise_1(i / 61.3f) * 0.2f + noise_1(i / 55.1f) * 0.2f) * HEIGHT);
int height = (int)((noise_1(i / 59.7f) * 0.35f + noise_1(i / 61.3f) * 0.25f + noise_1(i / 55.1f) * 0.25f) * HEIGHT);

for (int j = 0; j < HEIGHT; j++) {
if (j == HEIGHT - 1 && WORLD_WRAP) {
Expand All @@ -221,14 +221,23 @@ void world_gen(void) {

if (HEIGHT - j < height) {
int depth = HEIGHT - j;
int solid = 0;

if (noise_2(i / 47.0f, j / 43.0f) >= lerp(0.4f, 0.8f, depth / 50.0f)) {
set_tile(i, j, tile_stone);
solid = 1;
} else if (noise_2(i / 55.0f, j / 51.0f) >= lerp(0.6f, 0.9f, (height - depth) / 50.0f)) {
set_tile(i, j, tile_sand);
} else if (noise_2(i / 46.9f, j / 43.1f) >= lerp(0.35f, 0.7f, depth / 50.0f)) {
set_tile(i, j, tile_clay);
solid = 1;
} else {
set_tile(i, j, tile_dirt);
}

if (solid && noise_2(i / 17.3f, j / 16.2f) >= 0.85f) {
set_tile(i, j, (HEIGHT - j < 0.4f * HEIGHT) ? tile_water : tile_air);
}
} else if (HEIGHT - j < 0.4f * HEIGHT) {
set_tile(i, j, tile_water);
}
Expand Down

0 comments on commit 7200bfd

Please sign in to comment.