Changeset 7207 in orxonox.OLD for branches/std/src/world_entities/power_ups
- Timestamp:
- Mar 9, 2006, 11:35:50 PM (19 years ago)
- Location:
- branches/std/src/world_entities/power_ups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/world_entities/power_ups/power_up.cc
r7193 r7207 33 33 this->respawnStart = 10; 34 34 this->model = NULL; 35 /* if(!PowerUp::sphereModel) {*/35 /* if(!PowerUp::sphereModel) {*/ 36 36 37 37 Model* sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5); … … 75 75 76 76 77 void PowerUp::loadPickupSound(const char*pickupSound)77 void PowerUp::loadPickupSound(const std::string& pickupSound) 78 78 { 79 79 if (this->pickupBuffer != NULL) 80 80 ResourceManager::getInstance()->unload(this->pickupBuffer); 81 81 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 else90 {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 } 94 94 else 95 95 this->pickupBuffer = NULL; 96 96 } 97 97 98 void PowerUp::loadRespawnSound(const char*respawnSound)98 void PowerUp::loadRespawnSound(const std::string& respawnSound) 99 99 { 100 100 if (this->respawnBuffer != NULL) 101 101 ResourceManager::getInstance()->unload(this->respawnBuffer); 102 102 103 else if ( respawnSound != NULL)103 else if (!respawnSound.empty()) 104 104 { 105 105 this->respawnBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV); 106 106 if (this->respawnBuffer != NULL) 107 107 { 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()); 109 109 } 110 110 else 111 111 { 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()); 113 113 } 114 114 } … … 128 128 this->soundSource.play(this->pickupBuffer); 129 129 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; 138 139 } 139 140 } … … 141 142 } 142 143 143 void PowerUp::tick(float dt) { 144 if(this->getOMListNumber() != OM_COMMON) { 144 void PowerUp::tick(float dt) 145 { 146 if(this->getOMListNumber() != OM_COMMON) 147 { 145 148 this->respawnTime -= dt; 146 149 if(this->respawnTime <= 0) … … 157 160 void PowerUp::draw() const 158 161 { 159 if(this->model != NULL) { 162 if(this->model != NULL) 163 { 160 164 glMatrixMode(GL_MODELVIEW); 161 165 glPushMatrix(); … … 172 176 } 173 177 174 const char* PowerUp::respawnTypes[] = { 175 "none", 176 "time" 177 }; 178 const char* PowerUp::respawnTypes[] = 179 { 180 "none", 181 "time" 182 }; 178 183 179 184 void PowerUp::setRespawnType(const char* type) 180 185 { 181 for(int i = 0; i < RESPAWN_size; ++i) { 182 if(!strcmp(type, respawnTypes[i])) { 186 for(int i = 0; i < RESPAWN_size; ++i) 187 { 188 if(!strcmp(type, respawnTypes[i])) 189 { 183 190 this->respawnType = (PowerUpRespawn)i; 184 191 break; -
branches/std/src/world_entities/power_ups/power_up.h
r7102 r7207 26 26 void collidesWith (WorldEntity* entity, const Vector& location); 27 27 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); 30 30 31 31 virtual void draw () const;
Note: See TracChangeset
for help on using the changeset viewer.