Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6149


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

Introduced new feature: permanent speed

Location:
code/branches/presentation2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/defaultConfig/keybindings.ini

    r6108 r6149  
    147147
    148148[MouseButtons]
    149 MouseButton3=
    150 MouseButton4=
    151 MouseButton5=
    152 MouseButton6=
    153 MouseButton7=
    154 MouseLeft="fire 0"
    155 MouseMiddle=
    156 MouseRight="fire 1"
    157 MouseWheel1Down=
    158 MouseWheel1Up=
    159 MouseWheel2Down=
    160 MouseWheel2Up=
     149Button3=
     150Button4=
     151Button5=
     152Button6=
     153Button7=
    161154Left="fire 0"
     155Middle=
    162156Right="fire 1"
     157Wheel1Down="NewHumanController decelerate"
     158Wheel1Up="NewHumanController accelerate"
     159Wheel2Down=
     160Wheel2Up=
    163161
    164162[MouseAxes]
  • code/branches/presentation2/src/orxonox/controllers/HumanController.cc

    r6108 r6149  
    9595    }
    9696
    97     void HumanController::moveFrontBack(const Vector2& value)
     97    void HumanController::frontback(const Vector2& value)
    9898    {
    9999        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
  • code/branches/presentation2/src/orxonox/controllers/HumanController.h

    r6108 r6149  
    4545            virtual void tick(float dt);
    4646
    47             static void moveFrontBack(const Vector2& value);
     47            static void moveFrontBack(const Vector2& value){ HumanController::localController_s->frontback(value); }
    4848            static void moveRightLeft(const Vector2& value);
    4949            static void moveUpDown(const Vector2& value);
     
    5252            static void rotatePitch(const Vector2& value){ HumanController::localController_s->pitch(value); }
    5353            static void rotateRoll(const Vector2& value);
    54            
     54
     55            virtual void frontback(const Vector2& value);
    5556            virtual void yaw(const Vector2& value);
    5657            virtual void pitch(const Vector2& value);
  • 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}
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.h

    r6120 r6149  
    3232#include "OrxonoxPrereqs.h"
    3333
     34#include "util/Math.h"
     35
    3436#include "core/ClassTreeMask.h"
    3537#include "HumanController.h"
     
    4547            virtual void tick(float dt);
    4648
     49            virtual void frontback(const Vector2& value);
    4750            virtual void yaw(const Vector2& value);
    4851            virtual void pitch(const Vector2& value);
     52
     53            static void accelerate();
     54            static void decelerate();
    4955
    5056            virtual void doFire(unsigned int firemode);
    5157
    5258            static void changeMode();
    53            
     59
    5460            virtual void changedControllableEntity();
    5561
    5662        protected:
    5763            void updateTarget();
    58            
     64
    5965            unsigned int                controlMode_;
    6066            static NewHumanController*  localController_s;
     
    6470            OrxonoxOverlay*             crossHairOverlay_;
    6571            float                       overlaySize_;
     72            float                       currentAcceleration_;
     73            float                       acceleration_;
    6674            ClassTreeMask               targetMask_;
    6775    };
Note: See TracChangeset for help on using the changeset viewer.