polyadvent

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

commit eb9e01bd4485975d6e6b6cf3838cfbce147c8f01
parent ab2c88cbeb4b7b1ba9b804f4e796966dba663587
Author: William Casarin <jb55@jb55.com>
Date:   Wed,  7 Nov 2018 14:01:07 -0800

camera through world fixes

Diffstat:
Msrc/update.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/update.c b/src/update.c @@ -176,19 +176,20 @@ static void player_terrain_collision(struct terrain *terrain, struct entity *pla static void player_movement(struct game *game, struct entity *player) { movement(game, &player->node, 2.0); - /* vec3 *camera_world = node_world(&res->camera); */ - /* float cam_terrain_z = */ - /* game->terrain.fn(&game->terrain, camera_world[0], camera_world[1]); */ + vec3 *camera_world = node_world(&game->test_resources.camera.node); + float cam_terrain_z = + game->terrain.fn(&game->terrain, camera_world[0], camera_world[1]); - /* if (camera_world[2] < cam_terrain_z) */ - /* camera_world[2] = cam_terrain_z + 20.0; */ + const float bias = 20.0; + + if (camera_world[2] < cam_terrain_z + bias) + camera_world[2] = cam_terrain_z + bias; } #ifdef DEBUG static int try_reload_shaders(struct resources *res) { int ret; - static int wut = 0; for (int i = 0; i < NUM_PROGRAMS; ++i) { struct gpu_program *program = &res->programs[i]; ret = reload_program(program);