JA_IsMusicPlaying() added

This commit is contained in:
2021-02-03 21:39:28 +01:00
parent b8b2b417a9
commit 377c760e45
4 changed files with 13 additions and 0 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
*.exe
.vscode
*.out
main

View File

@@ -129,6 +129,10 @@ void JA_StopMusic() {
music.state = JA_MUSIC_STOPPED;
}
bool JA_IsMusicPlaying() {
return music.state == JA_MUSIC_PLAYING;
}
JA_Sound JA_LoadSound(const char* filename) {
JA_Sound sound = new JA_Sound_t();
SDL_AudioSpec wavSpec;

View File

@@ -9,6 +9,7 @@ void JA_PlayMusic(const char* filename, const bool loop = true);
void JA_PauseMusic();
void JA_RestartMusic();
void JA_StopMusic();
bool JA_IsMusicPlaying();
JA_Sound JA_LoadSound(const char* filename);
void JA_PlaySound(JA_Sound sound);

View File

@@ -20,6 +20,13 @@ int main(int argc, char **argv) {
if (event.type == SDL_QUIT) { should_exit = true; break; }
if (event.type == SDL_KEYDOWN) {
JA_PlaySound(peiv);
if (JA_IsMusicPlaying())
JA_PauseMusic();
else
{
JA_RestartMusic();
}
}
}
}