Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

powerups sounds when pickup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.