Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve issue #2 #30

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions src/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,53 @@ void create_world(int p, int q, world_func func, void *arg) {
int z = q * CHUNK_SIZE + dz;
float f = simplex2(x * 0.01, z * 0.01, 4, 0.5, 2);
float g = simplex2(-x * 0.01, -z * 0.01, 2, 0.9, 2);
int mh = g * 32 + 16;
int mh = g * 32 + 16;
int h = f * mh;
int w = 1;
int t = 12;
int t = 12; //related to block dimensions
if (h <= t) {
h = t;
w = 2;
}

/**
* I think this is what is determining where sand and grass blocks are placed up to a certain height
* by making the h value higher there will be more sand and grass blocks making the world feel 'deeper'
* potentially adding another layer of stone under the grass/sand could also create that feeling
* from the above code 't' appears to be the minimum possible for h, I will try making it much larger to see what
* happens and then reduce it to a more reasonable number
*
* t is not the number of block layers.... appears to have altered the block size and i was stuck in a single block
* much larger than the player when changing the value to 50
*
*
* */

// cobblestone terrain
/**
* @brief
* make bottom layer of cobblestone under the grass/sand layer
* cobble stone is block 11 in item array
* making it half the depth of the original grass/sand layer
*/
for (int y = 0; y < h/2; y++) {
func(x, y, z, 11 * flag, arg);
}
// sand and grass terrain
for (int y = 0; y < h; y++) {
// modifying parameters to start after the cobblestone level
for (int y = h/2; y < 1.5 * h; y++) {
func(x, y, z, w * flag, arg);
}
if (w == 1) {
if (SHOW_PLANTS) {
// grass
if (simplex2(-x * 0.1, z * 0.1, 4, 0.8, 2) > 0.6) {
func(x, h, z, 17 * flag, arg);
func(x, 1.5*h, z, 17 * flag, arg);
}
// flowers
if (simplex2(x * 0.05, -z * 0.05, 4, 0.8, 2) > 0.7) {
int w = 18 + simplex2(x * 0.1, z * 0.1, 4, 0.8, 2) * 7;
func(x, h, z, w * flag, arg);
func(x, 1.5*h, z, w * flag, arg);
}
}
// trees
Expand All @@ -46,18 +71,18 @@ void create_world(int p, int q, world_func func, void *arg) {
ok = 0;
}
if (ok && simplex2(x, z, 6, 0.5, 2) > 0.84) {
for (int y = h + 3; y < h + 8; y++) {
for (int y = 1.5*h + 3; y < 1.5*h + 8; y++) {
for (int ox = -3; ox <= 3; ox++) {
for (int oz = -3; oz <= 3; oz++) {
int d = (ox * ox) + (oz * oz) +
(y - (h + 4)) * (y - (h + 4));
(y - (1.5*h + 4)) * (y - (1.5*h + 4));
if (d < 11) {
func(x + ox, y, z + oz, 15, arg);
}
}
}
}
for (int y = h; y < h + 7; y++) {
for (int y = 1.5*h; y < 1.5*h + 7; y++) {
func(x, y, z, 5, arg);
}
}
Expand Down