Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mix_Music* playMusic(backgroundMusic bgmIndex) [80/194]
- {
- std::string filename;
- Mix_Music* musicFile;
- switch(bgmIndex)
- {
- case BGM_MENU_001:
- musicFile = Mix_LoadMUS("./output.ogg");
- break;
- }
- currentBgm = musicFile;
- return musicFile;
- }
- void playBgm(gameState state)
- {
- gameState c = state;
- switch (c)
- {
- case MENU:
- playMusic(BGM_MENU_001);
- break;
- default:
- playMusic(BGM_MENU_001);
- break;
- }
- }
- int gameMenu(void)
- {
- if (!Mix_PlayingMusic()) {
- if (NULL == currentBgm) {
- printf("Unable to load the bgm for the menu %s\n", Mix_GetError());
- return 1;
- }
- if(Mix_OpenAudio(22050, AUDIO_U16SYS, 2, 512) == -1)
- {
- cerr << "Unable to open audio device. Mix_GetError: " << Mix_GetError() << endl;
- }
- if (-1 == Mix_PlayMusic(currentBgm, LOOP_SOUND)) {
- printf("Unable to play the bgm for the menu %s\n", Mix_GetError());
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment