Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2009, 4:20:05 PM (14 years ago)
Author:
wirthmi
Message:

Introduced new feature: permanent speed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc

    r6144 r6149  
    4747{
    4848    SetConsoleCommand(NewHumanController, changeMode,          false).keybindMode(KeybindMode::OnPress);
     49    SetConsoleCommand(NewHumanController, accelerate,          false).keybindMode(KeybindMode::OnPress);
     50    SetConsoleCommand(NewHumanController, decelerate,          false).keybindMode(KeybindMode::OnPress);
    4951
    5052    CreateUnloadableFactory(NewHumanController);
     
    6062        overlaySize_ = 0.08;
    6163        controlMode_ = 0;
     64        acceleration_ = 0;
     65
     66        //currentPitch_ = 1;
     67        //currentYaw_ = 1;
    6268
    6369        if (GameMode::showsGraphics())
     
    98104                this->crossHairOverlay_->hide();
    99105            // TODO: update aimPosition of Pawn
     106
     107            if ( this->acceleration_ > 0 )
     108                HumanController::moveFrontBack(Vector2(clamp(this->acceleration_ + this->currentAcceleration_, 0.0f, 1.0f), 0));
    100109        }
    101110
     
    230239    }
    231240
     241    void NewHumanController::frontback(const Vector2& value)
     242    {
     243        this->currentAcceleration_ = value.x;
     244
     245        if (this->acceleration_ == 0)
     246            HumanController::frontback(value);
     247    }
     248
    232249    void NewHumanController::yaw(const Vector2& value)
    233250    {
     
    248265    }
    249266
    250     void NewHumanController::changeMode() {
     267    void NewHumanController::changeMode()
     268    {
    251269        if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0)
    252270        {
     
    264282        this->currentPitch_ = 0;
    265283    }
     284
     285    void NewHumanController::accelerate()
     286    {
     287        if ( NewHumanController::localController_s ) {
     288            NewHumanController::localController_s->acceleration_ += 0.08;
     289            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ + 0.08f, 0.0f, 1.0f);
     290        }
     291    }
     292
     293    void NewHumanController::decelerate()
     294    {
     295        if ( NewHumanController::localController_s ) {
     296            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.05f, 0.0f, 1.0f);
     297        }
     298    }
    266299}
Note: See TracChangeset for help on using the changeset viewer.