From d39b76f4331b0614659e15f45508e3c330fd05dc Mon Sep 17 00:00:00 2001 From: hikerstk Date: Tue, 5 Jan 2010 01:13:53 +0000 Subject: [PATCH] Applied Graham's 'reverse camera' patch, which changes to reverse camera when driving backwards faster than a certain speed (defined in user config). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4399 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/config/user_config.hpp | 3 +++ src/karts/player_kart.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 1a9df79ad..b24280e52 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -250,6 +250,9 @@ namespace UserConfigParams PARAM_PREFIX BoolUserConfigParam m_log_errors PARAM_DEFAULT( BoolUserConfigParam(false, "log_errors", "Enable logging of stdout and stderr to logfile") ); + PARAM_PREFIX IntUserConfigParam m_reverse_look_threshold + PARAM_DEFAULT( IntUserConfigParam(9, "reverse_look_threshold") ); + PARAM_PREFIX StringUserConfigParam m_item_style PARAM_DEFAULT( StringUserConfigParam("items", "item_style", "Name of the .items file to use.") ); diff --git a/src/karts/player_kart.cpp b/src/karts/player_kart.cpp index 7405e0666..f5fd447e9 100644 --- a/src/karts/player_kart.cpp +++ b/src/karts/player_kart.cpp @@ -278,9 +278,17 @@ void PlayerKart::update(float dt) if (m_powerup.getType()==POWERUP_NOTHING) Kart::beep(); } + + // Camera looks back when reversing if(m_camera->getMode()!=Camera::CM_FINAL) - m_camera->setMode(m_controls.m_look_back ? Camera::CM_REVERSE - : Camera::CM_NORMAL); + { + // look backward when the player requests or + // if automatic reverse camera is active + if (m_controls.m_look_back || (UserConfigParams::m_reverse_look_threshold>0 && Kart::getSpeed()<-UserConfigParams::m_reverse_look_threshold)) + m_camera->setMode(Camera::CM_REVERSE); + else + m_camera->setMode(Camera::CM_NORMAL); + } // We can't restrict rescue to fulfil isOnGround() (which would be more like // MK), since e.g. in the City track it is possible for the kart to end