[Orxonox-commit 1529] r6247 - code/branches/presentation2/src/modules/weapons/projectiles
youngk at orxonox.net
youngk at orxonox.net
Fri Dec 4 18:05:39 CET 2009
Author: youngk
Date: 2009-12-04 18:05:39 +0100 (Fri, 04 Dec 2009)
New Revision: 6247
Modified:
code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h
Log:
Implemented exhaust sound for rocket. Explosion sounds of any sort (either Rocket or Ship) do not work yet.
BUG: Firing sound won't attach to HsW01 specifically. Other weapons work.
Modified: code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc 2009-12-04 15:27:11 UTC (rev 6246)
+++ code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc 2009-12-04 17:05:39 UTC (rev 6247)
@@ -38,6 +38,8 @@
#include "controllers/Controller.h"
#include "worldentities/CameraPosition.h"
+#include "sound/WorldSound.h"
+
namespace orxonox
{
CreateFactory(Rocket);
@@ -85,18 +87,30 @@
camPosition->setPosition(0,4,15);
camPosition->setAllowMouseLook(true);
this->addCameraPosition(camPosition);
+
+ this->defSndWpnEngine_ = new WorldSound(this);
+ this->defSndWpnEngine_->setLooping(true);
+ this->defSndWpnEngine_->setSource("sounds/Rocket_Engine.ogg");
+ this->attach(defSndWpnEngine_);
}
/**
@brief
- Destructor. Destroys controller, if present.
+ Destructor. Destroys controller, if present and kills sounds, if playing.
*/
Rocket::~Rocket()
{
if(this->isInitialized())
{
if (GameMode::isMaster() && this->player_)
+ {
this->player_->stopTemporaryControl();
+ }
+ if(this->defSndWpnEngine_->isPlaying())
+ {
+ this->defSndWpnEngine_->stop();
+ }
+ delete this->defSndWpnEngine_;
}
}
@@ -116,6 +130,8 @@
this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
this->player_ = this->owner_->getPlayer();
this->owner_->getPlayer()->startTemporaryControl(this);
+
+ this->defSndWpnEngine_->play();
}
/**
@@ -184,7 +200,13 @@
void Rocket::destroyObject()
{
if (GameMode::isMaster())
+ {
+ if(this->defSndWpnEngine_->isPlaying())
+ {
+ this->defSndWpnEngine_->stop();
+ }
this->destroy();
+ }
}
void Rocket::fired(unsigned int firemode)
Modified: code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h 2009-12-04 15:27:11 UTC (rev 6246)
+++ code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h 2009-12-04 17:05:39 UTC (rev 6247)
@@ -121,6 +121,9 @@
WeakPtr<PlayerInfo> player_;
Timer destroyTimer_;
float lifetime_;
+
+ WorldSound* defSndWpnEngine_;
+ WorldSound* defSndWpnExplosion_;
};
}
More information about the Orxonox-commit
mailing list