Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 28, 2013, 3:58:45 PM (11 years ago)
Author:
thiweber
Message:

im Pong Score-Sound eingefuegt (PongBall.cc)

Location:
code/branches/sfxThilo/src/modules/pong
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sfxThilo/src/modules/pong/Pong.cc

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

    r9667 r9720  
    4040
    4141#include "PongBat.h"
     42
     43#include "sound/WorldSound.h" //Thilo
     44#include "core/XMLPort.h"
    4245
    4346namespace orxonox
     
    6669
    6770        this->registerVariables();
     71
     72        //Thilo
     73        if (GameMode::isMaster())
     74             {
     75                 this->defScoreSound_ = new WorldSound(this->getContext());
     76                 this->defScoreSound_->setLooping(false);
     77                 this->defBatSound_ = new WorldSound(this->getContext());
     78                 this->defBatSound_->setLooping(false);
     79                 this->defBoundarySound_ = new WorldSound(this->getContext());
     80                 this->defBoundarySound_->setLooping(false);
     81             }
     82             else
     83             {
     84                 this->defScoreSound_ = 0;
     85             }
    6886    }
    6987
     
    8199            delete[] this->batID_;
    82100        }
     101    }
     102
     103    //Thilo
     104    void PongBall::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     105    {
     106        SUPER(PongBall, XMLPort, xmlelement, mode);
     107        XMLPortParam(PongBall, "defScoreSound",  setDefScoreSound,  getDefScoreSound,  xmlelement, mode);
     108        XMLPortParam(PongBall, "defBatSound",  setDefBatSound,  getDefBatSound,  xmlelement, mode);
     109        XMLPortParam(PongBall, "defBoundarySound",  setDefBoundarySound,  getDefBoundarySound,  xmlelement, mode);
    83110    }
    84111
     
    155182                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    156183                    {
     184                        defScoreSound_->play();//Thilo
    157185                        if (this->getGametype() && this->bat_[0])
    158186                        {
     
    182210                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    183211                    {
     212                        defScoreSound_->play();//Thilo
    184213                        if (this->getGametype() && this->bat_[1])
    185214                        {
     
    262291            this->bat_[1] = orxonox_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
    263292    }
     293
     294    void PongBall::setDefScoreSound(const std::string &pongSound)
     295    {
     296        if( defScoreSound_ )
     297            defScoreSound_->setSource(pongSound);
     298        else
     299            assert(0); // This should never happen, because soundpointer is only available on master
     300    }
     301
     302    const std::string& PongBall::getDefScoreSound()
     303    {
     304        if( defScoreSound_ )
     305            return defScoreSound_->getSource();
     306        else
     307            assert(0);
     308        return BLANKSTRING;
     309    }
     310
     311    void PongBall::setDefBatSound(const std::string &pongSound)
     312    {
     313        if( defBatSound_ )
     314            defBatSound_->setSource(pongSound);
     315        else
     316            assert(0); // This should never happen, because soundpointer is only available on master
     317    }
     318
     319    const std::string& PongBall::getDefBatSound()
     320    {
     321        if( defBatSound_ )
     322            return defBatSound_->getSource();
     323        else
     324            assert(0);
     325        return BLANKSTRING;
     326    }
     327
     328    void PongBall::setDefBoundarySound(const std::string &pongSound)
     329    {
     330        if( defBoundarySound_ )
     331            defBoundarySound_->setSource(pongSound);
     332        else
     333            assert(0); // This should never happen, because soundpointer is only available on master
     334    }
     335
     336    const std::string& PongBall::getDefBoundarySound()
     337    {
     338        if( defBoundarySound_ )
     339            return defBoundarySound_->getSource();
     340        else
     341            assert(0);
     342        return BLANKSTRING;
     343    }
    264344}
  • code/branches/sfxThilo/src/modules/pong/PongBall.h

    r9667 r9720  
    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); //Thilo
     129            const std::string& getDefScoreSound(); //Thilo
     130
    125131        private:
    126132            void registerVariables();
     
    135141            unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
    136142            float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
     143            WorldSound* defScoreSound_;//Thilo
    137144    };
    138145}
  • code/branches/sfxThilo/src/modules/pong/PongScore.cc

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

    r9667 r9720  
    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.