Bugfix: collectables didn't regenerate in follow-the-leader mode.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2139 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-06-25 06:18:16 +00:00
parent 370fa80994
commit fde307f5e7
2 changed files with 14 additions and 13 deletions

View File

@ -27,10 +27,10 @@
Herring::Herring(herringType type, const Vec3& xyz, ssgEntity* model)
: m_coord(xyz, Vec3(0, 0, 0))
{
m_type = type;
m_eaten = false;
m_time_to_return = 0.0f; // not strictly necessary, see isEaten()
m_root = new ssgTransform();
m_type = type;
m_eaten = false;
m_time_till_return = 0.0f; // not strictly necessary, see isEaten()
m_root = new ssgTransform();
m_root->ref();
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
m_root->addKid(model);
@ -47,8 +47,8 @@ Herring::~Herring()
//-----------------------------------------------------------------------------
void Herring::reset()
{
m_eaten = false;
m_time_to_return = 0.0f;
m_eaten = false;
m_time_till_return = 0.0f;
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
} // reset
@ -63,12 +63,13 @@ void Herring::update(float delta)
{
if(m_eaten)
{
const float T = m_time_to_return - world->getTime();
if ( T > 0 )
m_time_till_return -= delta;
if ( m_time_till_return > 0 )
{
Vec3 hell(m_coord.getXYZ());
Vec3 hell(m_coord.getXYZ());
hell.setZ( (T>1.0f) ? -1000000.0f : m_coord.getXYZ().getZ() - T / 2.0f);
hell.setZ( (m_time_till_return>1.0f) ? -1000000.0f
: m_coord.getXYZ().getZ() - m_time_till_return / 2.0f);
m_root->setTransform(hell.toFloat());
}
else
@ -90,7 +91,7 @@ void Herring::update(float delta)
//-----------------------------------------------------------------------------
void Herring::isEaten()
{
m_eaten=true;
m_time_to_return=world->getTime()+2.0f;
m_eaten = true;
m_time_till_return = 2.0f;
}

View File

@ -36,7 +36,7 @@ class Herring
private:
herringType m_type; // Herring type
bool m_eaten; // true if herring was eaten & is not displayed
float m_time_to_return; // world->clock when an eaten herring reappears
float m_time_till_return; // time till an eaten herring reappears
Coord m_coord; // Original coordinates, used mainly when
// eaten herrings reappear.
ssgTransform* m_root; // The actual root of the herring