moved harcoded constant to config file

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2791 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2008-12-26 21:23:27 +00:00
parent 943fa76519
commit c008108f68
2 changed files with 4 additions and 9 deletions

View File

@ -5,9 +5,9 @@
(model "plunger.ac")
(icon "plunger-icon.rgb")
(speed 35.0)
(min-height 0.2) ; height above terrain below which a spark is
(min-height 0.2) ; height above terrain below which a plunger is
; started to be pulled up
(max-height 1.0) ; height above terrain at which a spark is
(max-height 1.0) ; height above terrain at which a plunger is
; started to be pulled back to ground
(force-updown 1.0) ; force pushing the spark down
; when it's too high above ground

View File

@ -127,19 +127,14 @@ void Plunger::update(float dt)
Flyable::update(dt);
if(!m_reverse_mode) m_rubber_band->update(dt);
// FIXME - don't hardcode, put in config file
const float max_height = 1.0;
const float min_height = 0.2;
const float average_height = (m_max_height + m_min_height)/2;
if(getHoT()==Track::NOHIT) return;
float hat = getTrans().getOrigin().getZ()-getHoT();
// Use the Height Above Terrain to set the Z velocity.
// HAT is clamped by min/max height. This might be somewhat
// unphysical, but feels right in the game.
hat = std::max(std::min(hat, max_height) , min_height);
float delta = average_height - hat;
hat = std::max(std::min(hat, m_max_height) , m_min_height);
float delta = m_average_height - hat;
btVector3 v=getVelocity();
v.setZ( /* up-down force */ 10*delta); // FIXME - don't hardcode, move to config file
setVelocity(v);