-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85f5a09
commit 5ddc323
Showing
6 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef AUDIO_HPP | ||
#define AUDIO_HPP | ||
|
||
|
||
void play_easter_egg(); | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <SDL2/SDL.h> | ||
#include <SDL2/SDL_mixer.h> | ||
|
||
#include "nightkingale_ogg.h" | ||
|
||
|
||
bool play_easter_egg() { | ||
// Initialize SDL_mixer. | ||
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { | ||
return false; | ||
} | ||
|
||
// Load the OGG file. | ||
SDL_RWops *rw = SDL_RWFromConstMem(nightkingale_ogg, nightkingale_ogg_size); | ||
Mix_Music *music = Mix_LoadMUS_RW(rw, 1); | ||
|
||
// Play the music once. | ||
Mix_PlayMusic(music, 1); | ||
|
||
// Wait for the music to finish. | ||
while (Mix_PlayingMusic()) { | ||
SDL_Delay(100); | ||
} | ||
|
||
// Clean up. | ||
Mix_FreeMusic(music); | ||
Mix_CloseAudio(); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters