remove procgen, use stb_perlin
This commit is contained in:
		| @@ -44,7 +44,7 @@ void game_tick(void) { | ||||
|         input_bind_action_scancode(&ctx.input, "ui_accept", SDL_SCANCODE_RETURN); | ||||
|  | ||||
|         input_add_action(&ctx.input, "mouse_capture_toggle"); | ||||
|         input_bind_action_scancode(&ctx.input, "mouse_capture_toggle", SDL_SCANCODE_END); | ||||
|         input_bind_action_scancode(&ctx.input, "mouse_capture_toggle", SDL_SCANCODE_ESCAPE); | ||||
|     } | ||||
|  | ||||
|     struct state *state = ctx.udata; | ||||
|   | ||||
| @@ -3,6 +3,10 @@ | ||||
| #include "scene.h" | ||||
|  | ||||
| #include "townengine/game_api.h" | ||||
| #include "townengine/tabela.h" | ||||
|  | ||||
| #define STB_PERLIN_IMPLEMENTATION | ||||
| #include <stb_perlin.h> | ||||
|  | ||||
|  | ||||
| static void ingame_tick(struct state *state) { | ||||
| @@ -82,12 +86,14 @@ static void ingame_tick(struct state *state) { | ||||
|  | ||||
|     set_camera(&cam); | ||||
|  | ||||
|     for (int y = 64; y--;) | ||||
|     #define TERRAIN_FREQUENCY 0.1f | ||||
|  | ||||
|     for (int y = 64; y--;) { | ||||
|         for (int x = 64; x--;) { | ||||
|             float d0 = sample_perlin_2d((t_fvec2){x, y}, 0.2, 5) * 8 - 6; | ||||
|             float d1 = sample_perlin_2d((t_fvec2){x + 1, y}, 0.2, 5) * 8 - 6; | ||||
|             float d2 = sample_perlin_2d((t_fvec2){x + 1, y - 1}, 0.2, 5) * 8 - 6; | ||||
|             float d3 = sample_perlin_2d((t_fvec2){x, y - 1}, 0.2, 5) * 8 - 6; | ||||
|             float d0 = stb_perlin_noise3((float)x       * TERRAIN_FREQUENCY, (float)y       * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 10 - 6; | ||||
|             float d1 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)y       * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 10 - 6; | ||||
|             float d2 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)(y - 1) * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 10 - 6; | ||||
|             float d3 = stb_perlin_noise3((float)x       * TERRAIN_FREQUENCY, (float)(y - 1) * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 10 - 6; | ||||
|  | ||||
|             unfurl_triangle("/assets/grass.gif", | ||||
|                             (t_fvec3){ x, d0, y }, | ||||
| @@ -105,6 +111,7 @@ static void ingame_tick(struct state *state) { | ||||
|                             (t_shvec2){ 0, 0 }, | ||||
|                             (t_shvec2){ 0, 768 }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user