JA_IsMusicPlaying() added
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
*.exe
|
*.exe
|
||||||
.vscode
|
.vscode
|
||||||
*.out
|
*.out
|
||||||
|
main
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ void JA_StopMusic() {
|
|||||||
music.state = JA_MUSIC_STOPPED;
|
music.state = JA_MUSIC_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JA_IsMusicPlaying() {
|
||||||
|
return music.state == JA_MUSIC_PLAYING;
|
||||||
|
}
|
||||||
|
|
||||||
JA_Sound JA_LoadSound(const char* filename) {
|
JA_Sound JA_LoadSound(const char* filename) {
|
||||||
JA_Sound sound = new JA_Sound_t();
|
JA_Sound sound = new JA_Sound_t();
|
||||||
SDL_AudioSpec wavSpec;
|
SDL_AudioSpec wavSpec;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ void JA_PlayMusic(const char* filename, const bool loop = true);
|
|||||||
void JA_PauseMusic();
|
void JA_PauseMusic();
|
||||||
void JA_RestartMusic();
|
void JA_RestartMusic();
|
||||||
void JA_StopMusic();
|
void JA_StopMusic();
|
||||||
|
bool JA_IsMusicPlaying();
|
||||||
|
|
||||||
JA_Sound JA_LoadSound(const char* filename);
|
JA_Sound JA_LoadSound(const char* filename);
|
||||||
void JA_PlaySound(JA_Sound sound);
|
void JA_PlaySound(JA_Sound sound);
|
||||||
|
|||||||
7
main.cpp
7
main.cpp
@@ -20,6 +20,13 @@ int main(int argc, char **argv) {
|
|||||||
if (event.type == SDL_QUIT) { should_exit = true; break; }
|
if (event.type == SDL_QUIT) { should_exit = true; break; }
|
||||||
if (event.type == SDL_KEYDOWN) {
|
if (event.type == SDL_KEYDOWN) {
|
||||||
JA_PlaySound(peiv);
|
JA_PlaySound(peiv);
|
||||||
|
if (JA_IsMusicPlaying())
|
||||||
|
JA_PauseMusic();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JA_RestartMusic();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user