[Orxonox-commit 3056] r7751 - in code/branches/presentation/src: modules/overlays/hud orxonox orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Thu Dec 9 12:45:33 CET 2010
Author: dafrick
Date: 2010-12-09 12:45:33 +0100 (Thu, 09 Dec 2010)
New Revision: 7751
Modified:
code/branches/presentation/src/modules/overlays/hud/HUDBar.cc
code/branches/presentation/src/orxonox/LevelManager.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Boost now runs out (and reloads).
Also fixed a few typos.
Modified: code/branches/presentation/src/modules/overlays/hud/HUDBar.cc
===================================================================
--- code/branches/presentation/src/modules/overlays/hud/HUDBar.cc 2010-12-08 18:33:11 UTC (rev 7750)
+++ code/branches/presentation/src/modules/overlays/hud/HUDBar.cc 2010-12-09 11:45:33 UTC (rev 7751)
@@ -84,7 +84,7 @@
.createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString()));
this->bar_->setMaterialName(materialname);
- this->value_ = 1.0f; // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
+ this->value_ = 1.0f; // initialize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
this->setAutoColour(true);
this->setValue(0.0f); // <--
this->setRightToLeft(false);
@@ -160,7 +160,7 @@
// set value
if (this->right2Left_)
{
- // backward casew
+ // backward case
this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f);
this->bar_->setDimensions(0.88f * this->value_, 1.0f);
}
Modified: code/branches/presentation/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/presentation/src/orxonox/LevelManager.cc 2010-12-08 18:33:11 UTC (rev 7750)
+++ code/branches/presentation/src/orxonox/LevelManager.cc 2010-12-09 11:45:33 UTC (rev 7751)
@@ -151,6 +151,7 @@
{
Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
// Iterate over all *.oxw level files.
+ COUT(3) << "Loading LevelInfos..." << std::endl;
for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
{
//TODO: Replace with tag,
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2010-12-08 18:33:11 UTC (rev 7750)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2010-12-09 11:45:33 UTC (rev 7751)
@@ -56,6 +56,12 @@
this->steering_ = Vector3::ZERO;
this->engine_ = 0;
+ this->boostPower_ = 10.0f;
+ this->initialBoostPower_ = 10.0f;
+ this->boostRate_ = 5.0;
+ this->boostPowerRate_ = 1.0;
+ this->boostCooldownDuration_ = 5.0;
+ this->bBoostCooldown_ = false;
this->bInvertYAxis_ = false;
@@ -85,6 +91,10 @@
XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode);
XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
XMLPortParamVariable(SpaceShip, "rotationThrust", rotationThrust_, xmlelement, mode);
+ XMLPortParamVariable(SpaceShip, "boostPower", initialBoostPower_, xmlelement, mode);
+ XMLPortParamVariable(SpaceShip, "boostPowerRate", boostPowerRate_, xmlelement, mode);
+ XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode);
+ XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
}
void SpaceShip::registerVariables()
@@ -133,8 +143,28 @@
this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
this->localAngularAcceleration_.setValue(0, 0, 0);
}
+
+ if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_)
+ {
+ this->boostPower_ += this->boostPowerRate_*dt;
+ }
+ if(this->bBoost_)
+ {
+ this->boostPower_ -=this->boostRate_*dt;
+ if(this->boostPower_ <= 0.0f)
+ {
+ this->bBoost_ = false;
+ this->bBoostCooldown_ = true;
+ this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
+ }
+ }
}
}
+
+ void SpaceShip::boostCooledDown(void)
+ {
+ this->bBoostCooldown_ = false;
+ }
void SpaceShip::moveFrontBack(const Vector2& value)
{
@@ -174,6 +204,20 @@
Pawn::rotateRoll(value);
}
+
+ // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
+ void SpaceShip::setBoost(bool bBoost)
+ {
+ if(bBoost == this->bBoost_)
+ return;
+
+ if(bBoost)
+ this->boost();
+ else
+ {
+ this->bBoost_ = false;
+ }
+ }
void SpaceShip::fire()
{
@@ -181,7 +225,8 @@
void SpaceShip::boost()
{
- this->bBoost_ = true;
+ if(!this->bBoostCooldown_)
+ this->bBoost_ = true;
}
void SpaceShip::loadEngineTemplate()
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2010-12-08 18:33:11 UTC (rev 7750)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2010-12-09 11:45:33 UTC (rev 7751)
@@ -33,6 +33,7 @@
#include <string>
#include <LinearMath/btVector3.h>
+#include "tools/Timer.h"
#include "util/Math.h"
#include "Pawn.h"
@@ -68,8 +69,7 @@
inline const Vector3& getSteeringDirection() const
{ return this->steering_; }
- inline void setBoost(bool bBoost)
- { this->bBoost_ = bBoost; }
+ void setBoost(bool bBoost);
inline bool getBoost() const
{ return this->bBoost_; }
@@ -88,7 +88,13 @@
bool bInvertYAxis_;
bool bBoost_;
+ bool bBoostCooldown_;
bool bPermanentBoost_;
+ float boostPower_;
+ float initialBoostPower_;
+ float boostRate_;
+ float boostPowerRate_;
+ float boostCooldownDuration_;
Vector3 steering_;
float primaryThrust_;
float auxilaryThrust_;
@@ -101,9 +107,12 @@
virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
void loadEngineTemplate();
+
+ void boostCooledDown(void);
std::string enginetemplate_;
Engine* engine_;
+ Timer timer_;
};
}
More information about the Orxonox-commit
mailing list