Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 22, 2010, 7:24:24 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation2 branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc

    r7547 r7801  
    5757        this->engine_ = 0;
    5858
     59        this->boostPower_ = 10.0f;
     60        this->initialBoostPower_ = 10.0f;
     61        this->boostRate_ = 5.0;
     62        this->boostPowerRate_ = 1.0;
     63        this->boostCooldownDuration_ = 5.0;
     64        this->bBoostCooldown_ = false;
    5965
    6066        this->bInvertYAxis_ = false;
     
    8692        XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
    8793        XMLPortParamVariable(SpaceShip, "rotationThrust", rotationThrust_, xmlelement, mode);
     94        XMLPortParamVariable(SpaceShip, "boostPower", initialBoostPower_, xmlelement, mode);
     95        XMLPortParamVariable(SpaceShip, "boostPowerRate", boostPowerRate_, xmlelement, mode);
     96        XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode);
     97        XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
    8898    }
    8999
     
    134144                this->localAngularAcceleration_.setValue(0, 0, 0);
    135145            }
    136         }
     146           
     147            if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_)
     148            {
     149                this->boostPower_ += this->boostPowerRate_*dt;
     150            }
     151            if(this->bBoost_)
     152            {
     153                this->boostPower_ -=this->boostRate_*dt;
     154                if(this->boostPower_ <= 0.0f)
     155                {
     156                    this->bBoost_ = false;
     157                    this->bBoostCooldown_ = true;
     158                    this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
     159                }
     160            }
     161        }
     162    }
     163   
     164    void SpaceShip::boostCooledDown(void)
     165    {
     166        this->bBoostCooldown_ = false;
    137167    }
    138168
     
    175205        Pawn::rotateRoll(value);
    176206    }
     207   
     208    // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
     209    void SpaceShip::setBoost(bool bBoost)
     210    {
     211        if(bBoost == this->bBoost_)
     212            return;
     213   
     214        if(bBoost)
     215            this->boost();
     216        else
     217        {
     218            this->bBoost_ = false;
     219        }
     220    }
    177221
    178222    void SpaceShip::fire()
     
    182226    void SpaceShip::boost()
    183227    {
    184         this->bBoost_ = true;
     228        if(!this->bBoostCooldown_)
     229            this->bBoost_ = true;
    185230    }
    186231
Note: See TracChangeset for help on using the changeset viewer.