Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8541


Ignore:
Timestamp:
May 23, 2011, 3:50:13 PM (13 years ago)
Author:
dboehi
Message:

Changed boost to start on key press and stop on key release

Location:
code/branches/gameimmersion
Files:
5 edited

Legend:

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

    r8079 r8541  
    2121KeyDown="scale -1 moveFrontBack"
    2222KeyE="scale -1 rotateRoll"
    23 KeyEnd=boost
     23KeyEnd=
    2424KeyEquals=
    2525KeyEscape="keyESC"
     
    120120KeySlash=
    121121KeySleep=
    122 KeySpace=boost
     122KeySpace=startBoost | stopBoost
    123123KeyStop=
    124124KeySystemRequest=
  • code/branches/gameimmersion/data/levels/templates/spaceshipImmTest.oxt

    r8395 r8541  
    2020   linearDamping     = 0.7
    2121   angularDamping    = 0.9999999
     22   
     23   shakeFrequency    = 15
    2224  >
    2325    <attached>
  • code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc

    r8379 r8541  
    5252    SetConsoleCommand("HumanController", __CC_fire_name,           &HumanController::fire          ).addShortcut().keybindMode(KeybindMode::OnHold);
    5353    SetConsoleCommand("HumanController", "reload",                 &HumanController::reload        ).addShortcut();
    54     SetConsoleCommand("HumanController", __CC_boost_name,          &HumanController::toggleBoost   ).addShortcut().keybindMode(KeybindMode::OnPress);
     54    //SetConsoleCommand("HumanController", __CC_boost_name,          &HumanController::toggleBoost   ).addShortcut().keybindMode(KeybindMode::OnPress);
     55    SetConsoleCommand("HumanController", "startBoost",             &HumanController::startBoost    ).addShortcut().keybindMode(KeybindMode::OnPress);
     56    SetConsoleCommand("HumanController", "stopBoost",              &HumanController::stopBoost     ).addShortcut().keybindMode(KeybindMode::OnRelease);
    5557    SetConsoleCommand("HumanController", "greet",                  &HumanController::greet         ).addShortcut();
    5658    SetConsoleCommand("HumanController", "switchCamera",           &HumanController::switchCamera  ).addShortcut();
     
    171173    /*static*/ void HumanController::toggleBoost()
    172174    {
     175        COUT(0) << "Toggling boost!";
    173176        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    174177            HumanController::localController_s->toggleBoosting();
     
    182185    void HumanController::toggleBoosting(void)
    183186    {
     187            /*
    184188        this->boosting_ = !this->boosting_;
    185189       
     
    190194            ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress);
    191195
    192         this->controllableEntity_->boost(this->boosting_);
    193     }
     196        this->controllableEntity_->boost(this->boosting_);*/
     197    }
     198   
     199    void HumanController::startBoost()
     200    {
     201            COUT(0) << "Starting boost" << std::endl;
     202            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     203                    HumanController::localController_s->setBoost(true);
     204    }
     205   
     206    void HumanController::stopBoost()
     207    {
     208            COUT(0) << "Stopping boost" << std::endl;
     209            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     210                    HumanController::localController_s->setBoost(false);
     211    }
     212   
     213    void HumanController::setBoost(bool bBoost)
     214    {
     215            this->controllableEntity_->boost(bBoost);
     216    }       
    194217
    195218    void HumanController::greet()
  • code/branches/gameimmersion/src/orxonox/controllers/HumanController.h

    r8379 r8541  
    6464            static void reload();
    6565
     66            static void startBoost();
     67            static void stopBoost();
    6668            static void toggleBoost(); // Static method,toggles boosting.
     69            void setBoost(bool);
    6770            /**
    6871            @brief Check whether the HumanController is in boosting mode.
  • code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8490 r8541  
    168168            }
    169169
    170            // COUT(0) << "Velocity: " << this->getVelocity().length() << " - " << this->getVelocity().squaredLength() << std::endl;
    171 
    172 
    173170            if(this->bBoost_)
    174171            {
     
    186183        }
    187184    }
     185
     186    void SpaceShip::moveFrontBack(const Vector2& value)
     187    {
     188        this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
     189        this->steering_.z = -value.x;
     190    }
     191
     192    void SpaceShip::moveRightLeft(const Vector2& value)
     193    {
     194        this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
     195        this->steering_.x = value.x;
     196    }
     197
     198    void SpaceShip::moveUpDown(const Vector2& value)
     199    {
     200        this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
     201        this->steering_.y = value.x;
     202    }
     203
     204    void SpaceShip::rotateYaw(const Vector2& value)
     205    {
     206        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
     207
     208        Pawn::rotateYaw(value);
     209    }
     210
     211    void SpaceShip::rotatePitch(const Vector2& value)
     212    {
     213        this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
     214
     215        Pawn::rotatePitch(value);
     216    }
     217
     218    void SpaceShip::rotateRoll(const Vector2& value)
     219    {
     220        this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
     221
     222        Pawn::rotateRoll(value);
     223    }
     224
     225    void SpaceShip::fire()
     226    {
     227    }
     228
     229    /**
     230    @brief
     231        Starts or stops boosting.
     232    @param bBoost
     233        Whether to start or stop boosting.
     234    */
     235    void SpaceShip::boost(bool bBoost)
     236    {   
     237        if(bBoost && !this->bBoostCooldown_)
     238        {
     239            //COUT(0) << "Boost startet!\n";
     240            this->bBoost_ = true;
     241        }
     242        if(!bBoost)
     243        {
     244            //COUT(0) << "Boost stoppt\n";
     245            this->resetCamera();
     246            this->bBoost_ = false;
     247        }
     248    }
     249   
     250    void SpaceShip::boostCooledDown(void)
     251    {
     252            this->bBoostCooldown_ = false;
     253    }
    188254   
    189255    void SpaceShip::shakeCamera(float dt)
    190256    {
     257            //make sure the ship is only shaking if it's moving
    191258            if (this->getVelocity().squaredLength() > 80)
    192259            {
     
    208275                    if (c != 0)
    209276                    {
    210                         c->setOrientation(Vector3::UNIT_X, angle);
     277                            c->setOrientation(Vector3::UNIT_X, angle);
    211278                    }
    212279            }
    213280    }
    214 
    215 
    216     void SpaceShip::boostCooledDown(void)
    217     {
    218         this->bBoostCooldown_ = false;
    219     }
    220 
    221     void SpaceShip::moveFrontBack(const Vector2& value)
    222     {
    223         this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
    224         this->steering_.z = -value.x;
    225     }
    226 
    227     void SpaceShip::moveRightLeft(const Vector2& value)
    228     {
    229         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
    230         this->steering_.x = value.x;
    231     }
    232 
    233     void SpaceShip::moveUpDown(const Vector2& value)
    234     {
    235         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
    236         this->steering_.y = value.x;
    237     }
    238 
    239     void SpaceShip::rotateYaw(const Vector2& value)
    240     {
    241         this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
    242 
    243         Pawn::rotateYaw(value);
    244     }
    245 
    246     void SpaceShip::rotatePitch(const Vector2& value)
    247     {
    248         this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
    249 
    250         Pawn::rotatePitch(value);
    251     }
    252 
    253     void SpaceShip::rotateRoll(const Vector2& value)
    254     {
    255         this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
    256 
    257         Pawn::rotateRoll(value);
    258     }
    259 
    260     void SpaceShip::fire()
    261     {
    262     }
    263 
    264     /**
    265     @brief
    266         Starts or stops boosting.
    267     @param bBoost
    268         Whether to start or stop boosting.
    269     */
    270     void SpaceShip::boost(bool bBoost)
    271     {   
    272         if(bBoost && !this->bBoostCooldown_)
    273         {
    274 //          COUT(0) << "Boost startet!\n";
    275             this->bBoost_ = true;
    276         }
    277         if(!bBoost)
    278         {
    279 //          COUT(0) << "Boost stoppt\n";
    280             this->resetCamera();
    281             this->bBoost_ = false;
    282         }
     281   
     282    void SpaceShip::resetCamera()
     283    {
     284           
     285//          COUT(0) << "Resetting camera\n";
     286            Camera *c = this->getCamera();
     287         
     288            if (c == 0)
     289            {
     290                    COUT(2) << "Failed to reset camera!";
     291                    return;
     292            }
     293           
     294            shakeDt_ = 0;
     295            //     
     296            c->setPosition(this->cameraOriginalPosition);
     297            c->setOrientation(this->cameraOriginalOrientation);
    283298    }
    284299
     
    326341    }
    327342   
    328     void SpaceShip::resetCamera()
    329     {
    330            
    331 //          COUT(0) << "Resetting camera\n";
    332             Camera *c = this->getCamera();
    333          
    334             if (c == 0)
    335             {
    336                     COUT(2) << "Failed to reset camera!";
    337                     return;
    338             }
    339            
    340             shakeDt_ = 0;
    341 //         
    342             c->setPosition(this->cameraOriginalPosition);
    343             c->setOrientation(this->cameraOriginalOrientation);
    344     }
     343
    345344}
Note: See TracChangeset for help on using the changeset viewer.