Camera distance based on speed speed-camera
authorAlberto Mardegan <mardy@users.sourceforge.net>
Sat, 9 Jul 2011 08:43:09 +0000 (11:43 +0300)
committerAlberto Mardegan <mardy@users.sourceforge.net>
Sat, 9 Jul 2011 08:43:09 +0000 (11:43 +0300)
ball/game_common.h
ball/game_server.c

index 458baf5..d42ba02 100644 (file)
@@ -52,6 +52,7 @@ enum
     VIEW_CHASE,
     VIEW_LAZY,
     VIEW_MANUAL,
+    VIEW_SPEED,
 
     VIEW_MAX
 };
index b82bd45..04f8710 100644 (file)
@@ -561,6 +561,14 @@ static void game_update_view(float dt)
         v_mad(view.e[2], view.e[2], view_v, v_dot(view_v, view_v) * dt / 4);
 
         break;
+
+    case VIEW_SPEED:  /* View vector chases the ball position, height depends
+                         on speed. */
+
+        v_sub(view.e[2], view.p, view.c);
+
+        break;
+
     }
 
     /* Apply manual rotation. */
@@ -579,6 +587,13 @@ static void game_update_view(float dt)
     /* Compute the new view position. */
 
     k = 1.0f + v_dot(view.e[2], view_v) / 10.0f;
+    if (input_get_c() == VIEW_SPEED)
+    {
+        float speed_adj = v_dot(vary.uv->v, vary.uv->v) / 10.0;
+        if (speed_adj > 5.0)
+            speed_adj = 5.0;
+        k += speed_adj;
+    }
 
     view_k = view_k + (k - view_k) * dt;