Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2013, 3:43:45 PM (11 years ago)
Author:
smerkli
Message:

Merged sfxThilo branch, things seem to be working fine

Location:
code/branches/presentationHS13
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS13

  • code/branches/presentationHS13/src/modules/pong/Pong.cc

    r9667 r9918  
    4747#include "PongBot.h"
    4848#include "PongAI.h"
     49
    4950namespace orxonox
    5051{
     
    117118            }
    118119        }
     120
    119121    }
    120122
  • code/branches/presentationHS13/src/modules/pong/PongBall.cc

    r9667 r9918  
    4040
    4141#include "PongBat.h"
     42
     43#include "sound/WorldSound.h"
     44#include "core/XMLPort.h"
    4245
    4346namespace orxonox
     
    6669
    6770        this->registerVariables();
     71
     72        //initialize sound
     73        if (GameMode::isMaster())
     74             {
     75                 this->defScoreSound_ = new WorldSound(this->getContext());
     76                 this->defScoreSound_->setVolume(1.0f);
     77                 this->defBatSound_ = new WorldSound(this->getContext());
     78                 this->defBatSound_->setVolume(0.4f);
     79                 this->defBoundarySound_ = new WorldSound(this->getContext());
     80                 this->defBoundarySound_->setVolume(0.5f);
     81             }
     82             else
     83             {
     84                 this->defScoreSound_ = 0;
     85                 this->defBatSound_ = 0;
     86                 this->defBoundarySound_ = 0;
     87             }
    6888    }
    6989
     
    81101            delete[] this->batID_;
    82102        }
     103    }
     104
     105    //xml port for loading sounds
     106    void PongBall::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     107    {
     108        SUPER(PongBall, XMLPort, xmlelement, mode);
     109        XMLPortParam(PongBall, "defScoreSound",  setDefScoreSound,  getDefScoreSound,  xmlelement, mode);
     110        XMLPortParam(PongBall, "defBatSound",  setDefBatSound,  getDefBatSound,  xmlelement, mode);
     111        XMLPortParam(PongBall, "defBoundarySound",  setDefBoundarySound,  getDefBoundarySound,  xmlelement, mode);
    83112    }
    84113
     
    117146        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    118147        {
    119             // Its velocity in z-direction is inverted (i.e. it bounces off).
     148            defBoundarySound_->play(); //play boundary sound
     149                // Its velocity in z-direction is inverted (i.e. it bounces off).
    120150            velocity.z = -velocity.z;
    121151            // And its position is set as to not overstep the boundary it has just crossed.
     
    142172                    if (fabs(distance) <= 1) // If the bat is there to parry.
    143173                    {
    144                         // Set the ball to be exactly at the boundary.
     174                        defBatSound_->play(); //play bat sound
     175                        // Set the ball to be exactly at the boundary.
    145176                        position.x = this->fieldWidth_ / 2;
    146177                        // Invert its velocity in x-direction (i.e. it bounces off).
     
    155186                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    156187                    {
     188                        defScoreSound_->play();//play score sound
    157189                        if (this->getGametype() && this->bat_[0])
    158190                        {
     
    169201                    if (fabs(distance) <= 1) // If the bat is there to parry.
    170202                    {
    171                         // Set the ball to be exactly at the boundary.
     203                        defBatSound_->play(); //play bat sound
     204                        // Set the ball to be exactly at the boundary.
    172205                        position.x = -this->fieldWidth_ / 2;
    173206                        // Invert its velocity in x-direction (i.e. it bounces off).
     
    182215                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    183216                    {
     217                        defScoreSound_->play();//play score sound
    184218                        if (this->getGametype() && this->bat_[1])
    185219                        {
     
    262296            this->bat_[1] = orxonox_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
    263297    }
     298
     299    void PongBall::setDefScoreSound(const std::string &pongSound)
     300    {
     301        if( defScoreSound_ )
     302            defScoreSound_->setSource(pongSound);
     303        else
     304            assert(0); // This should never happen, because soundpointer is only available on master
     305    }
     306
     307    const std::string& PongBall::getDefScoreSound()
     308    {
     309        if( defScoreSound_ )
     310            return defScoreSound_->getSource();
     311        else
     312            assert(0);
     313        return BLANKSTRING;
     314    }
     315
     316    void PongBall::setDefBatSound(const std::string &pongSound)
     317    {
     318        if( defBatSound_ )
     319            defBatSound_->setSource(pongSound);
     320        else
     321            assert(0); // This should never happen, because soundpointer is only available on master
     322    }
     323
     324    const std::string& PongBall::getDefBatSound()
     325    {
     326        if( defBatSound_ )
     327            return defBatSound_->getSource();
     328        else
     329            assert(0);
     330        return BLANKSTRING;
     331    }
     332
     333    void PongBall::setDefBoundarySound(const std::string &pongSound)
     334    {
     335        if( defBoundarySound_ )
     336            defBoundarySound_->setSource(pongSound);
     337        else
     338            assert(0); // This should never happen, because soundpointer is only available on master
     339    }
     340
     341    const std::string& PongBall::getDefBoundarySound()
     342    {
     343        if( defBoundarySound_ )
     344            return defBoundarySound_->getSource();
     345        else
     346            assert(0);
     347        return BLANKSTRING;
     348    }
    264349}
  • code/branches/presentationHS13/src/modules/pong/PongBall.h

    r9667 r9918  
    4242#include "worldentities/MovableEntity.h"
    4343
     44
    4445namespace orxonox
    4546{
     
    6364
    6465            virtual void tick(float dt);
     66
     67            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    6568
    6669            /**
     
    123126            static const float MAX_REL_Z_VELOCITY;
    124127
     128            void setDefScoreSound(const std::string& engineSound);
     129            const std::string& getDefScoreSound();
     130            void setDefBatSound(const std::string& engineSound);
     131            const std::string& getDefBatSound();
     132            void setDefBoundarySound(const std::string& engineSound);
     133            const std::string& getDefBoundarySound();
     134
    125135        private:
    126136            void registerVariables();
     
    135145            unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
    136146            float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
     147            WorldSound* defScoreSound_;
     148            WorldSound* defBatSound_;
     149            WorldSound* defBoundarySound_;
    137150    };
    138151}
  • code/branches/presentationHS13/src/modules/pong/PongScore.cc

    r9667 r9918  
    4141
    4242#include "Pong.h"
     43#include "sound/WorldSound.h" /////////////////////////////
    4344
    4445namespace orxonox
  • code/branches/presentationHS13/src/modules/pong/PongScore.h

    r9667 r9918  
    124124            WeakPtr<PlayerInfo> player1_; //!< Store information about left player permanently.
    125125            WeakPtr<PlayerInfo> player2_; //!< Same for the right player. To end the game properly.
     126            WorldSound* scoreSound_;
     127
    126128    };
    127129}
Note: See TracChangeset for help on using the changeset viewer.