/apps/scenery: make the world generate as you go
This commit is contained in:
		| @@ -56,8 +56,11 @@ static void ingame_tick(State *state) { | |||||||
|  |  | ||||||
|     #define TERRAIN_FREQUENCY 0.1f |     #define TERRAIN_FREQUENCY 0.1f | ||||||
|  |  | ||||||
|     for (int y = 64; y--;) { |     for (int ly = 64; ly--;) { | ||||||
|         for (int x = 64; x--;) { |         for (int lx = 64; lx--;) { | ||||||
|  |             float x = SDL_truncf(scn->cam.pos.x + 32 - lx); | ||||||
|  |             float y = SDL_truncf(scn->cam.pos.z + 32 - ly); | ||||||
|  |  | ||||||
|             float d0 = stb_perlin_noise3((float)x       * TERRAIN_FREQUENCY, (float)y       * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; |             float d0 = stb_perlin_noise3((float)x       * TERRAIN_FREQUENCY, (float)y       * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; | ||||||
|             float d1 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)y       * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; |             float d1 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)y       * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; | ||||||
|             float d2 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)(y - 1) * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; |             float d2 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)(y - 1) * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user