# HG changeset patch # User John Tsiombikas # Date 1412357784 -10800 # Node ID df3a70664a7d4ef61c5c6ea8159b8fbffcdea6e4 # Parent 3f221bdc9bab5528bb7661b7ca6877801586c713 falling diff -r 3f221bdc9bab -r df3a70664a7d src/game.cc --- a/src/game.cc Fri Oct 03 04:16:16 2014 +0300 +++ b/src/game.cc Fri Oct 03 20:36:24 2014 +0300 @@ -28,9 +28,12 @@ static unsigned int chess_tex; static float cam_theta = -90, cam_phi; -static Vector3 cam_pos = {15.4, 0, 0}; +static Vector3 cam_pos = Vector3(15.4, 0, 0); static bool keystate[256]; +static float cam_vvel; +static const float grav = -9.8; + static Console con; static dtx_font *con_font; @@ -130,7 +133,15 @@ cam_pos.z += dir.x * sin_theta + dir.z * cos_theta; float max_step = get_gvar_num(GVAR_MAX_STEP); - cam_pos = scn.find_walk_pos(cam_pos + Vector3(0, max_step, 0)); + Vector3 floor_pos = scn.find_walk_pos(cam_pos + Vector3(0, max_step, 0)); + + if(floor_pos.y < cam_pos.y) { + cam_vvel += grav * dt; + cam_pos.y += cam_vvel * dt; + if(cam_pos.y < floor_pos.y) { + cam_pos.y = floor_pos.y; + } + } } void game_display()