Changeset 3108 for code/trunk/src/orxonox
- Timestamp:
- May 29, 2009, 12:46:24 AM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 4 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 } -
code/trunk/src/orxonox/sound/SoundBase.cc
r3078 r3108 97 97 alSourcei(this->source_, AL_LOOPING, AL_FALSE); 98 98 alSourcePlay(this->source_); 99 100 if(alGetError() != AL_NO_ERROR) 101 { 102 COUT(2) << "Sound: OpenAL: Error playin sound " << this->source_ << std::endl; 103 } 99 104 } 100 105 } … … 161 166 alGenSources(1, &this->source_); 162 167 alSourcei(this->source_, AL_BUFFER, this->buffer_); 163 // ALenum164 168 if(alGetError() != AL_NO_ERROR) { 165 169 COUT(2) << "Sound: OpenAL: Error loading sample file: " << filename << std::endl; -
code/trunk/src/orxonox/sound/SoundManager.cc
r3092 r3108 52 52 else 53 53 { 54 COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;55 const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER);56 if (str == NULL)57 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;58 else59 COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << str << std::endl;60 54 if(SoundManager::device_s == NULL) 61 55 { … … 82 76 if(alcMakeContextCurrent(this->context_) == AL_TRUE) 83 77 COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl; 78 79 COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl; 80 const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER); 81 if (str == NULL) 82 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 83 else 84 COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << str << std::endl; 84 85 } 85 86 }
Note: See TracChangeset
for help on using the changeset viewer.