Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7065 in orxonox.OLD


Ignore:
Timestamp:
Feb 7, 2006, 1:13:58 PM (18 years ago)
Author:
bensch
Message:

powerups sounds when pickup

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/sound_source.h

    r6981 r7065  
    3333    /** @returns true, if the Source is Playing */
    3434    inline bool   isPlaying() const { return this->bPlay; };
     35    /** @param sourceNode the Source this is attached to. */
     36    inline void setSourceNode(const PNode* sourceNode) { this->sourceNode = sourceNode;};
    3537    /** @returns the SoundBuffer of this Source */
    3638    inline const SoundBuffer* getBuffer() const { return this->buffer; }
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r6815 r7065  
    3838};
    3939
    40 ParamPowerUp::ParamPowerUp () : PowerUp(0.0, 1.0, 0.0)
    41 {
    42   this->init();
    43 }
    44 
    4540ParamPowerUp::ParamPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0)
    4641{
    4742  this->init();
     43  this->loadPickupSound("sound/powerups/power_up_6.wav");
    4844  if( root != NULL)
    4945    this->loadParams(root);
  • trunk/src/world_entities/power_ups/param_power_up.h

    r6547 r7065  
    2222
    2323public:
    24   ParamPowerUp();
    25   ParamPowerUp(const TiXmlElement* root);
     24  ParamPowerUp(const TiXmlElement* root = NULL);
    2625  virtual ~ParamPowerUp ();
    2726
  • trunk/src/world_entities/power_ups/power_up.cc

    r6973 r7065  
    2121#include "primitive_model.h"
    2222
     23#include "resource_manager.h"
    2324#include "load_param.h"
    2425
     
    4243  this->sphereMaterial->setDiffuse(r, g, b);
    4344  this->toList(OM_COMMON);
     45
     46  this->soundSource.setSourceNode(this);
     47  this->soundBuffer = NULL;
    4448}
    4549
     
    4751{
    4852  delete this->sphereMaterial;
     53  if (this->soundBuffer != NULL)
     54    ResourceManager::getInstance()->unload(this->soundBuffer);
    4955}
    5056
     
    5359{
    5460  WorldEntity::loadParams(root);
     61
    5562  LoadParam(root, "respawnType", this, PowerUp, setRespawnType);
     63
    5664  LoadParam(root, "respawnTime", this, PowerUp, setRespawnTime);
     65
     66  LoadParam(root, "pickup-sound", this, PowerUp, loadPickupSound);
    5767}
    5868
     69
     70void PowerUp::loadPickupSound(const char* pickupSound)
     71{
     72  if (this->soundBuffer != NULL)
     73    ResourceManager::getInstance()->unload(this->soundBuffer);
     74
     75  else if (pickupSound != NULL)
     76{
     77  this->soundBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV);
     78  if (this->soundBuffer != NULL)
     79  {
     80    PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound, this->getName());
     81  }
     82  else
     83  {
     84    PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound, this->getName());
     85  }
     86}
     87  else
     88    this->soundBuffer = NULL;
     89}
    5990
    6091void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
     
    6495    if(dynamic_cast<Extendable*>(entity)->pickup(this))
    6596    {
     97      if(soundBuffer != NULL)
     98        this->soundSource.play(this->soundBuffer);
     99
    66100      switch(respawnType) {
    67101        case RESPAWN_NONE:
  • trunk/src/world_entities/power_ups/power_up.h

    r6973 r7065  
    88
    99#include "world_entity.h"
     10
     11#include "sound_buffer.h"
     12#include "sound_source.h"
    1013
    1114class Material;
     
    2326  void collidesWith (WorldEntity* entity, const Vector& location);
    2427
     28  void loadPickupSound(const char* pickupSound);
     29
    2530  virtual void draw () const;
    2631  virtual void tick(float dt);
     
    3742
    3843private:
     44  SoundSource    soundSource;
     45  SoundBuffer*   soundBuffer;
    3946  Material* sphereMaterial;
    4047  PowerUpRespawn respawnType;
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r6815 r7065  
    2626
    2727CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP);
    28 
    29 TurretPowerUp::TurretPowerUp () : PowerUp(0.0, 1.0, 0.0)
    30 {
    31   this->init();
    32 }
    3328
    3429TurretPowerUp::TurretPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0)
  • trunk/src/world_entities/power_ups/turret_power_up.h

    r6512 r7065  
    1515
    1616 public:
    17   TurretPowerUp();
    18   TurretPowerUp(const TiXmlElement* root);
     17  TurretPowerUp(const TiXmlElement* root = NULL);
    1918  virtual ~TurretPowerUp ();
    2019
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r6973 r7065  
    3131CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP);
    3232
    33 WeaponPowerUp::WeaponPowerUp () : PowerUp(1.0, 1.0, 0.0)
    34 {
    35   this->init();
    36 }
    37 
    3833WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(1.0, 1.0, 0.0)
    3934{
    4035  this->init();
     36  this->loadPickupSound("sound/powerups/whats this2.wav");
    4137  if( root != NULL)
    4238    this->loadParams(root);
  • trunk/src/world_entities/power_ups/weapon_power_up.h

    r6973 r7065  
    1616
    1717public:
    18   WeaponPowerUp();
    19   WeaponPowerUp(const TiXmlElement* root);
     18  WeaponPowerUp(const TiXmlElement* root = NULL);
    2019  virtual ~WeaponPowerUp ();
    2120
Note: See TracChangeset for help on using the changeset viewer.