Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7221 in orxonox.OLD for trunk/src/world_entities/power_ups


Ignore:
Timestamp:
Mar 15, 2006, 3:10:45 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

Location:
trunk/src/world_entities/power_ups
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r7193 r7221  
    8181}
    8282
    83 void ParamPowerUp::setType(const char* type)
     83void ParamPowerUp::setType(const std::string& type)
    8484{
    8585  for(int i = 0; i < POWERUP_PARAM_size; ++i) {
    86     if(strcmp(type, paramTypes[i]) == 0) {
     86    if(type == paramTypes[i]) {
    8787      this->type = (EnumParamPowerUpType)i;
    8888      break;
  • trunk/src/world_entities/power_ups/param_power_up.h

    r7065 r7221  
    2828  void setMaxValue(float value);
    2929  void setMinValue(float value);
    30   void setType(const char* type);
     30  void setType(const std::string& type);
    3131  EnumParamPowerUpType getType();
    3232  float getValue();
     
    4343
    4444private:
    45   static const char* paramTypes[];
    46   EnumParamPowerUpType type;
    47   float value;
    48   float max_value;
    49   float min_value;
     45  EnumParamPowerUpType    type;
     46  float                   value;
     47  float                   max_value;
     48  float                   min_value;
     49
     50  static const char*      paramTypes[];
     51
    5052};
    5153
  • trunk/src/world_entities/power_ups/power_up.cc

    r7193 r7221  
    3333  this->respawnStart = 10;
    3434  this->model = NULL;
    35 /*  if(!PowerUp::sphereModel) {*/
     35  /*  if(!PowerUp::sphereModel) {*/
    3636
    3737  Model* sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
     
    7575
    7676
    77 void PowerUp::loadPickupSound(const char* pickupSound)
     77void PowerUp::loadPickupSound(const std::string& pickupSound)
    7878{
    7979  if (this->pickupBuffer != NULL)
    8080    ResourceManager::getInstance()->unload(this->pickupBuffer);
    8181
    82   else if (pickupSound != NULL)
    83 {
    84   this->pickupBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV);
    85   if (this->pickupBuffer != NULL)
    86   {
    87     PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound, this->getName());
    88   }
    89   else
    90   {
    91     PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound, this->getName());
    92   }
    93 }
     82  else if (!pickupSound.empty())
     83  {
     84    this->pickupBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV);
     85    if (this->pickupBuffer != NULL)
     86    {
     87      PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound.c_str(), this->getName());
     88    }
     89    else
     90    {
     91      PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound.c_str(), this->getName());
     92    }
     93  }
    9494  else
    9595    this->pickupBuffer = NULL;
    9696}
    9797
    98 void PowerUp::loadRespawnSound(const char* respawnSound)
     98void PowerUp::loadRespawnSound(const std::string& respawnSound)
    9999{
    100100  if (this->respawnBuffer != NULL)
    101101    ResourceManager::getInstance()->unload(this->respawnBuffer);
    102102
    103   else if (respawnSound != NULL)
     103  else if (!respawnSound.empty())
    104104  {
    105105    this->respawnBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV);
    106106    if (this->respawnBuffer != NULL)
    107107    {
    108       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound, this->getName());
     108      PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound.c_str(), this->getName());
    109109    }
    110110    else
    111111    {
    112       PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound, this->getName());
     112      PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound.c_str(), this->getName());
    113113    }
    114114  }
     
    128128        this->soundSource.play(this->pickupBuffer);
    129129
    130       switch(respawnType) {
    131         case RESPAWN_NONE:
    132           this->toList(OM_DEAD);
    133           break;
    134         case RESPAWN_TIME:
    135           this->toList(OM_DEAD_TICK);
    136           this->respawnTime = this->respawnStart;
    137           break;
     130      switch(respawnType)
     131      {
     132      case RESPAWN_NONE:
     133        this->toList(OM_DEAD);
     134        break;
     135      case RESPAWN_TIME:
     136        this->toList(OM_DEAD_TICK);
     137        this->respawnTime = this->respawnStart;
     138        break;
    138139      }
    139140    }
     
    141142}
    142143
    143 void PowerUp::tick(float dt) {
    144   if(this->getOMListNumber() != OM_COMMON) {
     144void PowerUp::tick(float dt)
     145{
     146  if(this->getOMListNumber() != OM_COMMON)
     147  {
    145148    this->respawnTime -= dt;
    146149    if(this->respawnTime <= 0)
     
    157160void PowerUp::draw() const
    158161{
    159   if(this->model != NULL) {
     162  if(this->model != NULL)
     163  {
    160164    glMatrixMode(GL_MODELVIEW);
    161165    glPushMatrix();
     
    172176}
    173177
    174 const char* PowerUp::respawnTypes[] = {
    175   "none",
    176   "time"
    177 };
    178 
    179 void PowerUp::setRespawnType(const char* type)
    180 {
    181   for(int i = 0; i < RESPAWN_size; ++i) {
    182     if(!strcmp(type, respawnTypes[i])) {
     178const char* PowerUp::respawnTypes[] =
     179  {
     180    "none",
     181    "time"
     182  };
     183
     184
     185void PowerUp::setRespawnType(const std::string& type)
     186{
     187  for(int i = 0; i < RESPAWN_size; ++i)
     188  {
     189    if(type == respawnTypes[i])
     190    {
    183191      this->respawnType = (PowerUpRespawn)i;
    184192      break;
  • trunk/src/world_entities/power_ups/power_up.h

    r7102 r7221  
    2626  void collidesWith (WorldEntity* entity, const Vector& location);
    2727
    28   void loadPickupSound(const char* pickupSound);
    29   void loadRespawnSound(const char* pickupSound);
     28  void loadPickupSound(const std::string& pickupSound);
     29  void loadRespawnSound(const std::string& respawnSound);
    3030
    3131  virtual void draw () const;
    3232  virtual void tick(float dt);
    33   void setRespawnType(const char* type);
     33  void setRespawnType(const std::string& type);
    3434  void setRespawnTime(const float respawn);
    3535
     
    4545
    4646private:
    47   SoundSource    soundSource;
    48   SoundBuffer*   pickupBuffer;
    49   SoundBuffer*   respawnBuffer;
    50   Material* sphereMaterial;
    51   PowerUpRespawn respawnType;
    52   float respawnTime;
    53   float respawnStart;
    54   static const char* respawnTypes[];
     47  SoundSource         soundSource;
     48  SoundBuffer*        pickupBuffer;
     49  SoundBuffer*        respawnBuffer;
     50  Material*           sphereMaterial;
     51  PowerUpRespawn      respawnType;
     52  float               respawnTime;
     53  float               respawnStart;
     54  static const char*  respawnTypes[];
    5555
    56   WorldEntity* collider;
     56  WorldEntity*        collider;
    5757};
    5858
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r7193 r7221  
    9292}
    9393
    94 void WeaponPowerUp::setWeaponClass(const char* name)
     94void WeaponPowerUp::setWeaponClass(const std::string& name)
    9595{
    9696  this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name));
    9797  if (this->weapon == NULL)
    9898  {
    99     PRINTF(1)("Unable to load Weapon. %s\n", name);
     99    PRINTF(1)("Unable to load Weapon. %s\n", name.c_str());
    100100    this->weapon = dynamic_cast<Weapon*>(Factory::fabricate("Turret"));
    101101  }
  • trunk/src/world_entities/power_ups/weapon_power_up.h

    r7065 r7221  
    2222
    2323  Weapon* getWeapon();
    24   void setWeaponClass(const char* name);
     24  void setWeaponClass(const std::string& name);
    2525
    2626  virtual int writeBytes(const byte* data, int length, int sender);
Note: See TracChangeset for help on using the changeset viewer.