From 41976ce36719ca7bf774a6e8503e043b351f3343 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sat, 9 Jul 2011 11:43:09 +0300 Subject: [PATCH] Camera distance based on speed --- ball/game_common.h | 1 + ball/game_server.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ball/game_common.h b/ball/game_common.h index 458baf5..d42ba02 100644 --- a/ball/game_common.h +++ b/ball/game_common.h @@ -52,6 +52,7 @@ enum VIEW_CHASE, VIEW_LAZY, VIEW_MANUAL, + VIEW_SPEED, VIEW_MAX }; diff --git a/ball/game_server.c b/ball/game_server.c index b82bd45..04f8710 100644 --- a/ball/game_server.c +++ b/ball/game_server.c @@ -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; -- 1.7.9.5