Changeset 2839 for code/trunk/src/orxonox/objects/worldentities/PongBall.cc
- Timestamp:
- Mar 25, 2009, 3:26:06 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/worldentities/PongBall.cc
r2826 r2839 44 44 this->speed_ = 0; 45 45 this->bat_ = 0; 46 this->relMercyOffset_ = 0.05; 46 47 } 47 48 … … 67 68 if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2) 68 69 { 69 velocity.x = -velocity.x;70 70 float distance = 0; 71 71 72 if ( position.x > this->fieldWidth_ / 2)72 if (this->bat_) 73 73 { 74 position.x = this->fieldWidth_ / 2; 75 if (this->bat_ && this->bat_[1]) 74 if (position.x > this->fieldWidth_ / 2 && this->bat_[1]) 76 75 { 77 distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * this->batlength_/ 2);78 if ( this->getGametype() && this->bat_[0] && fabs(distance) >1)76 distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2); 77 if (fabs(distance) <= 1) 79 78 { 80 this->getGametype()->playerScored(this->bat_[0]->getPlayer()); 81 return; 79 position.x = this->fieldWidth_ / 2; 80 velocity.x = -velocity.x; 81 velocity.z = distance * distance * sgn(distance) * 1.5 * this->speed_; 82 } 83 else if (position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 84 { 85 if (this->getGametype() && this->bat_[0]) 86 { 87 this->getGametype()->playerScored(this->bat_[0]->getPlayer()); 88 return; 89 } 90 } 91 } 92 if (position.x < -this->fieldWidth_ / 2 && this->bat_[0]) 93 { 94 distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2); 95 if (fabs(distance) <= 1) 96 { 97 position.x = -this->fieldWidth_ / 2; 98 velocity.x = -velocity.x; 99 velocity.z = distance * distance * sgn(distance) * 1.5 * this->speed_; 100 } 101 else if (position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 102 { 103 if (this->getGametype() && this->bat_[1]) 104 { 105 this->getGametype()->playerScored(this->bat_[1]->getPlayer()); 106 return; 107 } 82 108 } 83 109 } 84 110 } 85 if (position.x < -this->fieldWidth_ / 2)86 {87 position.x = -this->fieldWidth_ / 2;88 if (this->bat_ && this->bat_[0])89 {90 distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * this->batlength_ / 2);91 if (this->getGametype() && this->bat_[1] && fabs(distance) > 1)92 {93 this->getGametype()->playerScored(this->bat_[1]->getPlayer());94 return;95 }96 }97 }98 99 velocity.z = distance * distance * sgn(distance) * 1.5 * this->speed_;100 111 } 101 112
Note: See TracChangeset
for help on using the changeset viewer.