[Orxonox-commit 5056] r9720 - in code/branches/sfxThilo: data/levels src/modules/pong src/orxonox/gamestates

thiweber at orxonox.net thiweber at orxonox.net
Mon Oct 28 15:58:46 CET 2013


Author: thiweber
Date: 2013-10-28 15:58:45 +0100 (Mon, 28 Oct 2013)
New Revision: 9720

Modified:
   code/branches/sfxThilo/data/levels/pong.oxw
   code/branches/sfxThilo/src/modules/pong/Pong.cc
   code/branches/sfxThilo/src/modules/pong/PongBall.cc
   code/branches/sfxThilo/src/modules/pong/PongBall.h
   code/branches/sfxThilo/src/modules/pong/PongScore.cc
   code/branches/sfxThilo/src/modules/pong/PongScore.h
   code/branches/sfxThilo/src/orxonox/gamestates/GSMainMenu.cc
Log:
im Pong Score-Sound eingefuegt (PongBall.cc)

Modified: code/branches/sfxThilo/data/levels/pong.oxw
===================================================================
--- code/branches/sfxThilo/data/levels/pong.oxw	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/data/levels/pong.oxw	2013-10-28 14:58:45 UTC (rev 9720)
@@ -33,7 +33,9 @@
 </Template>
 
 <Template name=pongball>
-  <PongBall>
+  <PongBall 
+   defScoreSound = "sounds/Button.ogg"
+   defBoundarySound = "sounds/Button_press2.ogg">
     <attached>
       <Model mesh="sphere.mesh" scale=2 />
       <!--Billboard scale=0.2 colour="1.0, 1.0, 0.5" material="Examples/Flare" /-->

Modified: code/branches/sfxThilo/src/modules/pong/Pong.cc
===================================================================
--- code/branches/sfxThilo/src/modules/pong/Pong.cc	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/src/modules/pong/Pong.cc	2013-10-28 14:58:45 UTC (rev 9720)
@@ -46,6 +46,7 @@
 #include "PongBat.h"
 #include "PongBot.h"
 #include "PongAI.h"
+
 namespace orxonox
 {
     // Events to allow to react to scoring of a player, in the level-file.
@@ -116,6 +117,7 @@
                 this->bat_[0] = 0;
             }
         }
+
     }
 
     /**

Modified: code/branches/sfxThilo/src/modules/pong/PongBall.cc
===================================================================
--- code/branches/sfxThilo/src/modules/pong/PongBall.cc	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/src/modules/pong/PongBall.cc	2013-10-28 14:58:45 UTC (rev 9720)
@@ -40,6 +40,9 @@
 
 #include "PongBat.h"
 
+#include "sound/WorldSound.h" //Thilo
+#include "core/XMLPort.h"
+
 namespace orxonox
 {
     RegisterClass(PongBall);
@@ -65,6 +68,21 @@
         this->relMercyOffset_ = 0.05f;
 
         this->registerVariables();
+
+        //Thilo
+        if (GameMode::isMaster())
+             {
+                 this->defScoreSound_ = new WorldSound(this->getContext());
+                 this->defScoreSound_->setLooping(false);
+                 this->defBatSound_ = new WorldSound(this->getContext());
+                 this->defBatSound_->setLooping(false);
+                 this->defBoundarySound_ = new WorldSound(this->getContext());
+                 this->defBoundarySound_->setLooping(false);
+             }
+             else
+             {
+                 this->defScoreSound_ = 0;
+             }
     }
 
     /**
@@ -82,6 +100,15 @@
         }
     }
 
+    //Thilo
+    void PongBall::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PongBall, XMLPort, xmlelement, mode);
+        XMLPortParam(PongBall, "defScoreSound",  setDefScoreSound,  getDefScoreSound,  xmlelement, mode);
+        XMLPortParam(PongBall, "defBatSound",  setDefBatSound,  getDefBatSound,  xmlelement, mode);
+        XMLPortParam(PongBall, "defBoundarySound",  setDefBoundarySound,  getDefBoundarySound,  xmlelement, mode);
+    }
+
     /**
     @brief
         Register variables to synchronize over the network.
@@ -154,6 +181,7 @@
                     // If the left player scores.
                     else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
                     {
+                    	defScoreSound_->play();//Thilo
                         if (this->getGametype() && this->bat_[0])
                         {
                             this->getGametype()->playerScored(this->bat_[0]->getPlayer());
@@ -181,6 +209,7 @@
                     // If the right player scores.
                     else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
                     {
+                    	defScoreSound_->play();//Thilo
                         if (this->getGametype() && this->bat_[1])
                         {
                             this->getGametype()->playerScored(this->bat_[1]->getPlayer());
@@ -261,4 +290,55 @@
         if (this->batID_[1] != OBJECTID_UNKNOWN)
             this->bat_[1] = orxonox_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
     }
+
+    void PongBall::setDefScoreSound(const std::string &pongSound)
+    {
+        if( defScoreSound_ )
+            defScoreSound_->setSource(pongSound);
+        else
+            assert(0); // This should never happen, because soundpointer is only available on master
+    }
+
+    const std::string& PongBall::getDefScoreSound()
+    {
+        if( defScoreSound_ )
+            return defScoreSound_->getSource();
+        else
+            assert(0);
+        return BLANKSTRING;
+    }
+
+    void PongBall::setDefBatSound(const std::string &pongSound)
+    {
+        if( defBatSound_ )
+            defBatSound_->setSource(pongSound);
+        else
+            assert(0); // This should never happen, because soundpointer is only available on master
+    }
+
+    const std::string& PongBall::getDefBatSound()
+    {
+        if( defBatSound_ )
+            return defBatSound_->getSource();
+        else
+            assert(0);
+        return BLANKSTRING;
+    }
+
+    void PongBall::setDefBoundarySound(const std::string &pongSound)
+    {
+        if( defBoundarySound_ )
+            defBoundarySound_->setSource(pongSound);
+        else
+            assert(0); // This should never happen, because soundpointer is only available on master
+    }
+
+    const std::string& PongBall::getDefBoundarySound()
+    {
+        if( defBoundarySound_ )
+            return defBoundarySound_->getSource();
+        else
+            assert(0);
+        return BLANKSTRING;
+    }
 }

Modified: code/branches/sfxThilo/src/modules/pong/PongBall.h
===================================================================
--- code/branches/sfxThilo/src/modules/pong/PongBall.h	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/src/modules/pong/PongBall.h	2013-10-28 14:58:45 UTC (rev 9720)
@@ -41,6 +41,7 @@
 
 #include "worldentities/MovableEntity.h"
 
+
 namespace orxonox
 {
 
@@ -63,6 +64,8 @@
 
             virtual void tick(float dt);
 
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
             /**
             @brief Set the dimensions of the playing field.
             @param width The width of the playing field.
@@ -122,6 +125,9 @@
 
             static const float MAX_REL_Z_VELOCITY;
 
+            void setDefScoreSound(const std::string& engineSound); //Thilo
+            const std::string& getDefScoreSound(); //Thilo
+
         private:
             void registerVariables();
 
@@ -134,6 +140,7 @@
             bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not.
             unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
             float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
+            WorldSound* defScoreSound_;//Thilo
     };
 }
 

Modified: code/branches/sfxThilo/src/modules/pong/PongScore.cc
===================================================================
--- code/branches/sfxThilo/src/modules/pong/PongScore.cc	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/src/modules/pong/PongScore.cc	2013-10-28 14:58:45 UTC (rev 9720)
@@ -40,6 +40,7 @@
 #include "infos/PlayerInfo.h"
 
 #include "Pong.h"
+#include "sound/WorldSound.h" /////////////////////////////
 
 namespace orxonox
 {

Modified: code/branches/sfxThilo/src/modules/pong/PongScore.h
===================================================================
--- code/branches/sfxThilo/src/modules/pong/PongScore.h	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/src/modules/pong/PongScore.h	2013-10-28 14:58:45 UTC (rev 9720)
@@ -123,6 +123,8 @@
             bool bShowRightPlayer_; //!< Whether the right player is shown.
             WeakPtr<PlayerInfo> player1_; //!< Store information about left player permanently.
             WeakPtr<PlayerInfo> player2_; //!< Same for the right player. To end the game properly.
+            WorldSound* scoreSound_;
+
     };
 }
 #endif /* _PongScore_H__ */

Modified: code/branches/sfxThilo/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/sfxThilo/src/orxonox/gamestates/GSMainMenu.cc	2013-10-28 14:58:20 UTC (rev 9719)
+++ code/branches/sfxThilo/src/orxonox/gamestates/GSMainMenu.cc	2013-10-28 14:58:45 UTC (rev 9720)
@@ -84,7 +84,7 @@
     GSMainMenu::~GSMainMenu()
     {
         if (GameMode::playsSound())
-            this->ambient_->destroy();
+            this->ambient_->destroy(); //CHECK Thilo destroy ?preDestroy()? !!!!!!!
 
         InputManager::getInstance().destroyState("MainMenuHackery");
 




More information about the Orxonox-commit mailing list