Changeset 5881 for code/branches/core5
- Timestamp:
- Oct 5, 2009, 6:28:21 PM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/modules/pong/PongBall.cc
r5738 r5881 41 41 const float PongBall::MAX_REL_Z_VELOCITY = 1.5; 42 42 43 PongBall::PongBall(BaseObject* creator) : MovableEntity(creator) 43 PongBall::PongBall(BaseObject* creator) 44 : MovableEntity(creator) 45 , sidesound_(NULL) 46 , batsound_(NULL) 47 , scoresound_(NULL) 44 48 { 45 49 RegisterObject(PongBall); … … 54 58 this->registerVariables(); 55 59 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"); 60 if (GameMode::playsSound()) 61 { 62 this->sidesound_ = new SoundBase(this); 63 this->sidesound_->loadFile("sounds/pong_side.wav"); 64 65 this->batsound_ = new SoundBase(this); 66 this->batsound_->loadFile("sounds/pong_bat.wav"); 67 68 this->scoresound_ = new SoundBase(this); 69 this->scoresound_->loadFile("sounds/pong_score.wav"); 70 } 71 } 72 73 PongBall::~PongBall() 74 { 75 if (this->sidesound_) 76 delete this->sidesound_; 77 if (this->batsound_) 78 delete this->batsound_; 79 if (this->scoresound_) 80 delete this->scoresound_; 64 81 } 65 82 … … 87 104 { 88 105 velocity.z = -velocity.z; 89 this->sidesound_->play(); 106 if (GameMode::playsSound()) 107 this->sidesound_->play(); 90 108 91 109 if (position.z > this->fieldHeight_ / 2) … … 109 127 velocity.x = -velocity.x; 110 128 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 111 this->batsound_->play(); 129 if (GameMode::playsSound()) 130 this->batsound_->play(); 112 131 } 113 132 else if (position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) … … 116 135 { 117 136 this->getGametype()->playerScored(this->bat_[0]->getPlayer()); 118 this->scoresound_->play(); 137 if (GameMode::playsSound()) 138 this->scoresound_->play(); 119 139 return; 120 140 } … … 129 149 velocity.x = -velocity.x; 130 150 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 131 this->batsound_->play(); 151 if (GameMode::playsSound()) 152 this->batsound_->play(); 132 153 } 133 154 else if (position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) … … 135 156 if (this->getGametype() && this->bat_[1]) 136 157 { 137 this->scoresound_->play(); 158 if (GameMode::playsSound()) 159 this->scoresound_->play(); 138 160 this->getGametype()->playerScored(this->bat_[1]->getPlayer()); 139 161 return; … … 157 179 { 158 180 velocity.z = -velocity.z; 159 this->sidesound_->play(); 181 if (GameMode::playsSound()) 182 this->sidesound_->play(); 160 183 161 184 if (position.z > this->fieldHeight_ / 2) … … 178 201 position.x = this->fieldWidth_ / 2; 179 202 velocity.x = -velocity.x; 180 this->batsound_->play(); 203 if (GameMode::playsSound()) 204 this->batsound_->play(); 181 205 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 182 206 } … … 189 213 position.x = -this->fieldWidth_ / 2; 190 214 velocity.x = -velocity.x; 191 this->batsound_->play(); 215 if (GameMode::playsSound()) 216 this->batsound_->play(); 192 217 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 193 218 } -
code/branches/core5/src/modules/pong/PongBall.h
r5738 r5881 41 41 public: 42 42 PongBall(BaseObject* creator); 43 virtual ~PongBall() {}43 virtual ~PongBall(); 44 44 45 45 virtual void tick(float dt); -
code/branches/core5/src/orxonox/sound/SoundManager.cc
r5878 r5881 73 73 else 74 74 COUT(4) << "OpenAL ALUT supported MIME types: " << str << std::endl; 75 ThrowException(InitialisationFailed, "Just testing");76 75 77 76 GameMode::setPlaysSound(true);
Note: See TracChangeset
for help on using the changeset viewer.