Changeset 3108 for code/trunk/src/orxonox/objects/worldentities
- Timestamp:
- May 29, 2009, 12:46:24 AM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/worldentities/PongBall.cc
r3084 r3108 33 33 #include "core/GameMode.h" 34 34 #include "objects/gametypes/Gametype.h" 35 #include "sound/SoundBase.h" 35 36 36 37 namespace orxonox … … 50 51 this->batID_[1] = OBJECTID_UNKNOWN; 51 52 this->relMercyOffset_ = 0.05; 52 53 53 54 this->registerVariables(); 54 } 55 55 56 this->sidesound_ = new SoundBase(this); 57 this->sidesound_->loadFile("sounds/pong_side.wav"); 58 59 this->batsound_ = new SoundBase(this); 60 this->batsound_->loadFile("sounds/pong_bat.wav"); 61 62 this->scoresound_ = new SoundBase(this); 63 this->scoresound_->loadFile("sounds/pong_score.wav"); 64 } 65 56 66 void PongBall::registerVariables() 57 67 { … … 77 87 { 78 88 velocity.z = -velocity.z; 89 this->sidesound_->play(); 79 90 80 91 if (position.z > this->fieldHeight_ / 2) … … 98 109 velocity.x = -velocity.x; 99 110 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 111 this->batsound_->play(); 100 112 } 101 113 else if (position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) … … 104 116 { 105 117 this->getGametype()->playerScored(this->bat_[0]->getPlayer()); 118 this->scoresound_->play(); 106 119 return; 107 120 } … … 116 129 velocity.x = -velocity.x; 117 130 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 131 this->batsound_->play(); 118 132 } 119 133 else if (position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) … … 121 135 if (this->getGametype() && this->bat_[1]) 122 136 { 137 this->scoresound_->play(); 123 138 this->getGametype()->playerScored(this->bat_[1]->getPlayer()); 124 139 return; … … 142 157 { 143 158 velocity.z = -velocity.z; 159 this->sidesound_->play(); 144 160 145 161 if (position.z > this->fieldHeight_ / 2) … … 162 178 position.x = this->fieldWidth_ / 2; 163 179 velocity.x = -velocity.x; 180 this->batsound_->play(); 164 181 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 165 182 } … … 172 189 position.x = -this->fieldWidth_ / 2; 173 190 velocity.x = -velocity.x; 191 this->batsound_->play(); 174 192 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 175 193 } -
code/trunk/src/orxonox/objects/worldentities/PongBall.h
r3084 r3108 44 44 45 45 virtual void tick(float dt); 46 46 47 47 void registerVariables(); 48 48 … … 65 65 void setBats(PongBat** bats) 66 66 { this->bat_ = bats; this->batID_[0] = this->bat_[0]->getObjectID(); this->batID_[1] = this->bat_[1]->getObjectID(); } 67 67 68 68 void applyBats() 69 69 { if(!this->bat_) this->bat_ = new PongBat*[2]; if(this->batID_[0] != OBJECTID_UNKNOWN) this->bat_[0] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0])); if(this->batID_[1] != OBJECTID_UNKNOWN) this->bat_[1] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); } … … 79 79 unsigned int* batID_; 80 80 float relMercyOffset_; 81 82 SoundBase* sidesound_; 83 SoundBase* batsound_; 84 SoundBase* scoresound_; 81 85 }; 82 86 }
Note: See TracChangeset
for help on using the changeset viewer.