This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 20th, 2013  |  syntax: C  |  size: 2.81 KB  |  views: 1,344  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "sound.h"
  2.  
  3. static Mix_Music *bgm = NULL;
  4. static Mix_Chunk *seBep = NULL;
  5. static Mix_Chunk *seBeep = NULL;
  6. static Mix_Chunk *seBeeep = NULL;
  7. static Mix_Chunk *seBeeeep = NULL;
  8. static Mix_Chunk *seBeeeeep = NULL;
  9. static Mix_Chunk *seBeeeeeep = NULL;
  10. static Mix_Chunk *seBeeeeeeep = NULL;
  11. static Mix_Chunk *seBeeeeeeeep = NULL;
  12. static Mix_Chunk *seRoundBegin = NULL;
  13. static Mix_Chunk *seCrash = NULL;
  14. static Mix_Chunk *seSpeed = NULL;
  15. static Mix_Chunk *seFreeze = NULL;
  16. static Mix_Chunk *seConfusion = NULL;
  17. static Mix_Chunk *seSharpturn = NULL;
  18. static Mix_Chunk *seTimestep = NULL;
  19. static Mix_Chunk *seMole = NULL;
  20. static Mix_Chunk *seWarp = NULL;
  21. static Mix_Chunk *seGhost = NULL;
  22. static Mix_Chunk *seDisable = NULL;
  23. static Mix_Chunk *seSwitch = NULL;
  24. static Mix_Chunk *sounds[N_SOUNDS];
  25.  
  26. /**
  27.  * Initializes the mixer and loads sound files.
  28.  *
  29.  * @return -1 on failiure, 0 else.
  30.  */
  31. int initSound(void)
  32. {
  33.     if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY * 2, MIX_DEFAULT_FORMAT,
  34.                       2, 512) == -1 )
  35.     {
  36.         return -1;
  37.     }
  38.  
  39.     if ((bgm = Mix_LoadMUS("data/sound/theme1.ogg")) == NULL) {
  40.         fileNotFound("data/sound/theme1.ogg");
  41.         return -1;
  42.     }
  43.  
  44.     if (loadSound(seBep, "bep", SOUND_BEP) == -1)
  45.         return -1;
  46.     if (loadSound(seBeep, "beep", SOUND_BEEP) == -1)
  47.         return -1;
  48.     if (loadSound(seBeeep, "beeep", SOUND_BEEEP) == -1)
  49.         return -1;
  50.     if (loadSound(seBeeeep, "beeeep", SOUND_BEEEEP) == -1)
  51.         return -1;
  52.     if (loadSound(seBeeeeep, "beeeeep", SOUND_BEEEEEP) == -1)
  53.         return -1;
  54.     if (loadSound(seBeeeeeep, "beeeeeep", SOUND_BEEEEEEP) == -1)
  55.         return -1;
  56.     if (loadSound(seBeeeeeeep, "beeeeeeep", SOUND_BEEEEEEEP) == -1)
  57.         return -1;
  58.     if (loadSound(seBeeeeeeeep, "beeeeeeeep", SOUND_BEEEEEEEEP) == -1)
  59.         return -1;
  60.     if (loadSound(seRoundBegin, "round_begin", SOUND_ROUND_BEGIN) == -1)
  61.         return -1;
  62.     if (loadSound(seCrash, "crash", SOUND_CRASH) == -1)
  63.         return -1;
  64.     if (loadSound(seSpeed, "speed", SOUND_SPEED) == -1)
  65.         return -1;
  66.     if (loadSound(seFreeze, "freeze", SOUND_FREEZE) == -1)
  67.         return -1;
  68.     if (loadSound(seConfusion, "confusion", SOUND_CONFUSION) == -1)
  69.         return -1;
  70.     if (loadSound(seSharpturn, "sharpturn", SOUND_SHARPTURN) == -1)
  71.         return -1;
  72.     if (loadSound(seTimestep, "timestep", SOUND_TIMESTEP) == -1)
  73.         return -1;
  74.     if (loadSound(seMole, "mole", SOUND_MOLE) == -1)
  75.         return -1;
  76.     if (loadSound(seWarp, "warp", SOUND_WARP) == -1)
  77.         return -1;
  78.     if (loadSound(seGhost, "ghost", SOUND_GHOST) == -1)
  79.         return -1;
  80.     if (loadSound(seDisable, "ghost", SOUND_DISABLE) == -1)
  81.         return -1;
  82.     if (loadSound(seSwitch, "switch", SOUND_SWITCH) == -1)
  83.         return -1;
  84.  
  85.     return 0;
  86. }
clone this paste RAW Paste Data