polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 6a99ea57109e758cd99a590fc6a3a622e8dcbe86
parent b73aca1505639d7ffcec636e22d10e18054a7b76
Author: William Casarin <jb55@jb55.com>
Date:   Wed,  2 May 2018 10:08:34 -0700

scale is just freq

Diffstat:
Msrc/game.c | 4++--
Msrc/render.c | 2+-
Msrc/terrain.c | 4++--
Msrc/update.c | 19++++++++++---------
Msrc/window.c | 2+-
5 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -27,7 +27,7 @@ void game_init(struct game *game) { struct terrain *terrain = &game->terrain; mat4 *light_dir = game->test_resources.light_dir; - const double size = 1000; + const double size = 5000; const double pdist = 1.7; terrain->settings = (struct perlin_settings){ @@ -38,7 +38,7 @@ void game_init(struct game *game) { .amplitude = 1.0, .ox = 0, .oy = 0, - .exp = 6.3, + .exp = 5.3, .scale = 1.0 }; diff --git a/src/render.c b/src/render.c @@ -99,7 +99,7 @@ init_gl(struct resources *resources, int width, int height) { assert(resources->fragment_shader != 0); // camera - mat4_perspective(90 /* fov */, (float)width / height, 1, 1000, resources->camera_persp); + mat4_perspective(90 /* fov */, (float)width / height, 1, 5000, resources->camera_persp); // Shader program resources->program = make_program(resources->vertex_shader, diff --git a/src/terrain.c b/src/terrain.c @@ -22,8 +22,8 @@ static const u32 plane_indices[] = { double old_noisy_boi(struct terrain *t, double x, double y) { /* return cos(x/10.0) * sin(y/10.0) * 20.0; */ struct perlin_settings *s = &t->settings; - x *= s->scale; - y *= s->scale; + /* x *= s->scale; */ + /* y *= s->scale; */ double e = perlin2d(x, y, s->freq, s->depth) + s->o1s * perlin2d(s->o1 * x, s->o1 * y, s->freq, s->depth) + s->o2s * perlin2d(s->o2 * x, s->o2 * y, s->freq, s->depth); diff --git a/src/update.c b/src/update.c @@ -47,8 +47,13 @@ static void movement(struct game *game, struct node *node) { /* if (game->input.keystates[SDL_SCANCODE_DOWN]) */ /* node_rotate(node, V3(-amt * 0.01, 0, 0)); */ - if (game->input.keystates[SDL_SCANCODE_P]) + if (game->input.keystates[SDL_SCANCODE_P]) { + printf("%f %f %f\n", + node->pos[0], + node->pos[1], + node->pos[2]); mat4_print(node->mat); + } } void update_terrain(struct game *game) { @@ -59,9 +64,6 @@ void update_terrain(struct game *game) { struct node *tnode = &game->test_resources.terrain_node; struct terrain *terrain = &game->terrain; - double ox = tnode->pos[0]; - double oy = tnode->pos[1]; - printf("updating terrain\n"); if (first) { @@ -74,18 +76,17 @@ void update_terrain(struct game *game) { for (int i = 0; i < 2; ++i) tnode->pos[i] = max(tnode->pos[i], 0); - double scale = tnode->pos[2] * 0.01; + double scale = tnode->pos[2] * 0.0015; if (scale == 0) scale = 1.0; printf("terrain %f %f %f\n", tnode->pos[0], tnode->pos[1], tnode->pos[2]); - ts->scale = scale; /* ts.o1s = fabs(sin(1/n) * 0.25); */ /* ts.o1 = fabs(cos(n*0.2) * 0.5); */ /* ts.o2s = fabs(cos(n+2) * 0.5); */ /* ts.o2 = fabs(sin(n*0.02) * 2); */ - ts->freq = scale * 0.15; - ts->amplitude = 2.0/scale; + ts->freq = scale * 0.05; + ts->amplitude = 50.0; if (terrain->fn) terrain_destroy(&game->terrain); @@ -102,7 +103,7 @@ void update_terrain(struct game *game) { free(terrain->samples); int n_samples = - (terrain->size * game->terrain.size) * scale*scale; + (terrain->size * game->terrain.size) * scale * scale; struct point *samples = uniform_samples(n_samples, game->terrain.size); diff --git a/src/window.c b/src/window.c @@ -9,7 +9,7 @@ void handle_resize(float *camera, int width, int height) { printf("resizing %d %d\n", width, height); glViewport( 0, 0, width, height ); - mat4_perspective(90 /* fov */, (float)width / height, 1, 4000, camera); + mat4_perspective(90 /* fov */, (float)width / height, 1, 20000, camera); /* glMatrixMode( GL_PROJECTION ); //Switch to setting the camera perspective */ /* Set the camera perspective */