Advertisement
Guest User

Untitled

a guest
May 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. enum SoundType{
  2.     BOSS_JOY,
  3.     BOSS_PAIN
  4. };
  5.  
  6. typedef map<SoundType, CIwSoundSpec*> SoundMap;//mapping of soundtype to the actual sound
  7. typedef pair<SoundType, CIwSoundSpec*> SoundPair;
  8. typedef map<SoundType, const char*> EffectMap;//mapping of soundtype to the sound filename
  9. typedef pair<SoundType, const char*> EffectPair;
  10.  
  11.  
  12. void SoundBoard::play_fx(SoundType fx)
  13. {
  14.     this->sounds.find(fx)->second->Play();
  15. }
  16.  
  17. void SoundBoard::load_sounds(string group, EffectMap mapping)
  18. {
  19.     string group_s = string(group);
  20.     int found = group_s.find_last_of("/\\") + 1;
  21.     this->group_name = group_s.substr(found);
  22.     CIwResManager* res = IwGetResManager();
  23.     res->LoadGroup(group.c_str());//load the group and loop through the mapping
  24.     EffectMap::iterator pos;
  25.     SoundMap* sounds_p = &this->sounds;
  26.  
  27.     for (pos = mapping.begin(); pos != mapping.end(); ++pos)
  28.     {
  29.         sounds_p->insert(SoundPair(pos->first, (CIwSoundSpec*)res->GetResNamed(pos->second, IW_SOUND_RESTYPE_SPEC)));
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement