CMusicHandler.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "stdafx.h"
  2. #include "CMusicHandler.h"
  3. void CMusicHandler::initMusics()
  4. {
  5. if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096)==-1)
  6. {
  7. printf("Mix_OpenAudio: %s\n", Mix_GetError());
  8. exit(2);
  9. }
  10. atexit(Mix_CloseAudio);
  11. AITheme0 = Mix_LoadMUS("MP3\\AITheme0.mp3");
  12. AITheme1 = Mix_LoadMUS("MP3\\AITHEME1.mp3");
  13. AITheme2 = Mix_LoadMUS("MP3\\AITHEME2.mp3");
  14. buildTown = Mix_LoadWAV("MP3\\BUILDTWN.wav");
  15. combat1 = Mix_LoadMUS("MP3\\COMBAT01.mp3");
  16. combat2 = Mix_LoadMUS("MP3\\COMBAT02.mp3");
  17. combat3 = Mix_LoadMUS("MP3\\COMBAT03.mp3");
  18. combat4 = Mix_LoadMUS("MP3\\COMBAT04.mp3");
  19. castleTown = Mix_LoadMUS("MP3\\CstleTown.mp3");
  20. defendCastle = Mix_LoadMUS("MP3\\Defend Castle.mp3");
  21. dirt = Mix_LoadMUS("MP3\\DIRT.mp3");
  22. dungeon = Mix_LoadMUS("MP3\\DUNGEON.mp3");
  23. elemTown = Mix_LoadMUS("MP3\\ElemTown.mp3");
  24. evilTheme = Mix_LoadMUS("MP3\\EvilTheme.mp3");
  25. fortressTown = Mix_LoadMUS("MP3\\FortressTown.mp3");
  26. goodTheme = Mix_LoadMUS("MP3\\GoodTheme.mp3");
  27. grass = Mix_LoadMUS("MP3\\GRASS.mp3");
  28. infernoTown = Mix_LoadMUS("MP3\\InfernoTown.mp3");
  29. lava = Mix_LoadMUS("MP3\\LAVA.mp3");
  30. loopLepr = Mix_LoadMUS("MP3\\LoopLepr.mp3");
  31. loseCampain = Mix_LoadMUS("MP3\\Lose Campain.mp3");
  32. loseCastle = Mix_LoadMUS("MP3\\LoseCastle.mp3");
  33. loseCombat = Mix_LoadMUS("MP3\\LoseCombat.mp3");
  34. mainMenu = Mix_LoadMUS("MP3\\MAINMENU.mp3");
  35. mainMenuWoG = Mix_LoadMUS("MP3\\MainMenuWoG.mp3");
  36. necroTown = Mix_LoadMUS("MP3\\necroTown.mp3");
  37. neutralTheme = Mix_LoadMUS("MP3\\NeutralTheme.mp3");
  38. rampart = Mix_LoadMUS("MP3\\RAMPART.mp3");
  39. retreatBattle = Mix_LoadMUS("MP3\\Retreat Battle.mp3");
  40. rough = Mix_LoadMUS("MP3\\ROUGH.mp3");
  41. sand = Mix_LoadMUS("MP3\\SAND.mp3");
  42. secretTheme = Mix_LoadMUS("MP3\\SecretTheme.mp3");
  43. snow = Mix_LoadMUS("MP3\\SNOW.mp3");
  44. stronghold = Mix_LoadMUS("MP3\\StrongHold.mp3");
  45. surrenderBattle = Mix_LoadMUS("MP3\\Surrender Battle.mp3");
  46. swamp = Mix_LoadMUS("MP3\\SWAMP.mp3");
  47. towerTown = Mix_LoadMUS("MP3\\TowerTown.mp3");
  48. ultimateLose = Mix_LoadMUS("MP3\\UltimateLose.mp3");
  49. underground = Mix_LoadMUS("MP3\\Underground.mp3");
  50. water = Mix_LoadMUS("MP3\\WATER.mp3");
  51. winBattle = Mix_LoadMUS("MP3\\Win Battle.mp3");
  52. winScenario = Mix_LoadMUS("MP3\\Win Scenario.mp3");
  53. click = Mix_LoadWAV("MP3\\snd1.wav");
  54. click->volume = 30;
  55. }
  56. void CMusicHandler::playClick()
  57. {
  58. int channel;
  59. channel = Mix_PlayChannel(-1, click, 0);
  60. if(channel == -1)
  61. {
  62. fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError());
  63. }
  64. }