vrheights
changeset 9:df3a70664a7d
falling
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 03 Oct 2014 20:36:24 +0300 |
parents | 3f221bdc9bab |
children | 3e6757655fe2 |
files | src/game.cc |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line diff
1.1 --- a/src/game.cc Fri Oct 03 04:16:16 2014 +0300 1.2 +++ b/src/game.cc Fri Oct 03 20:36:24 2014 +0300 1.3 @@ -28,9 +28,12 @@ 1.4 static unsigned int chess_tex; 1.5 1.6 static float cam_theta = -90, cam_phi; 1.7 -static Vector3 cam_pos = {15.4, 0, 0}; 1.8 +static Vector3 cam_pos = Vector3(15.4, 0, 0); 1.9 static bool keystate[256]; 1.10 1.11 +static float cam_vvel; 1.12 +static const float grav = -9.8; 1.13 + 1.14 static Console con; 1.15 static dtx_font *con_font; 1.16 1.17 @@ -130,7 +133,15 @@ 1.18 cam_pos.z += dir.x * sin_theta + dir.z * cos_theta; 1.19 1.20 float max_step = get_gvar_num(GVAR_MAX_STEP); 1.21 - cam_pos = scn.find_walk_pos(cam_pos + Vector3(0, max_step, 0)); 1.22 + Vector3 floor_pos = scn.find_walk_pos(cam_pos + Vector3(0, max_step, 0)); 1.23 + 1.24 + if(floor_pos.y < cam_pos.y) { 1.25 + cam_vvel += grav * dt; 1.26 + cam_pos.y += cam_vvel * dt; 1.27 + if(cam_pos.y < floor_pos.y) { 1.28 + cam_pos.y = floor_pos.y; 1.29 + } 1.30 + } 1.31 } 1.32 1.33 void game_display()