Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 28, 2008, 8:30:25 PM (16 years ago)
Author:
rgrieder
Message:
  • Wrote Clock() class: It starts an internal clock when GSRoot starts and gets handed to all GameState ticks as reference. You can then either query the ticked time or the real time (for instance for statistical measurements)
  • general clean up in all the game states
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/gamestates/GSLevel.cc

    r1672 r1674  
    4444    GSLevel::GSLevel(const std::string& name)
    4545        : GameState(name)
    46         , timefactor_(1.0f)
     46        , timeFactor_(1.0f)
    4747        , keyBinder_(0)
    4848        , inputState_(0)
     
    7474        hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
    7575        Loader::load(hud_);
     76
     77        // reset game speed to normal
     78        timeFactor_ = 1.0f;
    7679    }
    7780
     
    9699    }
    97100
    98     void GSLevel::ticked(float dt, uint64_t time)
     101    void GSLevel::ticked(const Clock& time)
    99102    {
    100103        // Call those objects that need the real time
    101104        for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
    102             it->tick(dt);
     105            it->tick(time.getDeltaTime());
    103106        // Call the scene objects
    104107        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    105             it->tick(dt * this->timefactor_);
     108            it->tick(time.getDeltaTime() * this->timeFactor_);
    106109    }
    107110
     
    112115    void GSLevel::setTimeFactor(float factor)
    113116    {
    114         float change = factor / this->timefactor_;
    115         this->timefactor_ = factor;
     117        float change = factor / this->timeFactor_;
     118        this->timeFactor_ = factor;
    116119        for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
    117120            it->setSpeedFactor(it->getSpeedFactor() * change);
    118121
    119122        for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it)
    120             it->setTimeFactor(timefactor_);
     123            it->setTimeFactor(timeFactor_);
    121124    }
    122125
Note: See TracChangeset for help on using the changeset viewer.