polyadvent

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

commit a8fe237277541fc3e8ac61558fc789a9f3b1f73a
parent 7449f5ea1ee2b6e20475d3b2425ea3b9ccda3450
Author: William Casarin <jb55@jb55.com>
Date:   Tue,  1 May 2018 21:50:20 -0700

fix horrible bug

Diffstat:
Msrc/game.c | 3++-
Msrc/terrain.c | 1+
Msrc/update.c | 5+++--
3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -38,7 +38,8 @@ void game_init(struct game *game) { .amplitude = 1.0, .ox = 0, .oy = 0, - .exp = 6.3 + .exp = 6.3, + .scale = 1.0 }; terrain_init(terrain); diff --git a/src/terrain.c b/src/terrain.c @@ -44,6 +44,7 @@ void terrain_init(struct terrain *terrain) { terrain->samples = NULL; terrain->n_samples = 0; + terrain->fn = 0; } double offset_fn(struct terrain* terrain, double x, double y) { diff --git a/src/update.c b/src/update.c @@ -87,14 +87,15 @@ void update_terrain(struct game *game) { ts->freq = scale * 0.15; ts->amplitude = 2.0/scale; - terrain_destroy(&game->terrain); + if (terrain->fn) + terrain_destroy(&game->terrain); /* const double pdist = min(5.0, max(1.1, 1.0/scale*1.4)); */ /* printf("pdist %f\n", pdist); */ - if (last_scale == -1 || fabs(scale - last_scale) > 0.00001) { + if (last_scale == -1.0 || fabs(scale - last_scale) > 0.00001) { printf("generating new samples\n"); if (terrain->samples)