Changeset 2839 for code/trunk/src/orxonox/objects/worldentities/PongBat.cc
- Timestamp:
- Mar 25, 2009, 3:26:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/worldentities/PongBat.cc
r2826 r2839 46 46 this->length_ = 0.25; 47 47 this->fieldHeight_ = 100; 48 this->bSteadiedPosition_ = false; 48 49 49 50 this->registerVariables(); … … 61 62 if (this->hasLocalController()) 62 63 { 63 this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_; 64 if (this->movement_ != 0) 65 { 66 this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_; 64 67 65 if (this->bMoveLocal_)66 this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));67 else68 this->setVelocity(0, 0, this->movement_);68 if (this->bMoveLocal_) 69 this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0)); 70 else 71 this->setVelocity(0, 0, this->movement_); 69 72 70 this->movement_ = 0; 73 this->movement_ = 0; 74 this->bSteadiedPosition_ = false; 75 } 76 else if (!this->bSteadiedPosition_) 77 { 78 // To ensure network synchronicity 79 this->setVelocity(0, 0, 0); 80 this->setPosition(this->getPosition()); 81 this->bSteadiedPosition_ = true; 82 } 71 83 } 72 84 73 85 SUPER(PongBat, tick, dt); 74 86 75 if (this->hasLocalController()) 76 { 77 Vector3 position = this->getPosition(); 78 79 if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2) 80 position.z = this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2; 81 if (position.z < -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2) 82 position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2; 83 84 if (position != this->getPosition()) 85 this->setPosition(position); 86 } 87 Vector3 position = this->getPosition(); 88 if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2) 89 position.z = this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2; 90 if (position.z < -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2) 91 position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2; 92 if (position != this->getPosition()) 93 this->setPosition(position); 87 94 } 88 95 … … 98 105 this->movement_ = value.x; 99 106 } 107 108 void PongBat::changedPlayer() 109 { 110 this->setVelocity(0, 0, 0); 111 } 100 112 }
Note: See TracChangeset
for help on using the changeset viewer.