aboutsummaryrefslogtreecommitdiff
path: root/examples/audio_module_playing.c
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-09-15 11:53:16 +0200
committerraysan5 <raysan5@gmail.com>2016-09-15 11:53:16 +0200
commit79c8eb543ef93fbfbc4073c6c4ea71e22e7e02c4 (patch)
tree03c6c40184cb26776b8e9ed52d06f73fe5c007a5 /examples/audio_module_playing.c
parent9923fe51a7f69f94c765cfe0dbbf718f287a7a2f (diff)
downloadraylib-79c8eb543ef93fbfbc4073c6c4ea71e22e7e02c4.tar.gz
raylib-79c8eb543ef93fbfbc4073c6c4ea71e22e7e02c4.zip
Corrected audio bugs and improved examples
Diffstat (limited to 'examples/audio_module_playing.c')
-rw-r--r--examples/audio_module_playing.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/examples/audio_module_playing.c b/examples/audio_module_playing.c
index fe9ea15c..7da3579c 100644
--- a/examples/audio_module_playing.c
+++ b/examples/audio_module_playing.c
@@ -62,6 +62,7 @@ int main()
PlayMusicStream(xm);
float timePlayed = 0.0f;
+ bool pause = false;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -71,7 +72,29 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- for (int i = MAX_CIRCLES - 1; i >= 0; i--)
+ UpdateMusicStream(xm); // Update music buffer with new stream data
+
+ // Restart music playing (stop and play)
+ if (IsKeyPressed(KEY_SPACE))
+ {
+ StopMusicStream(xm);
+ PlayMusicStream(xm);
+ }
+
+ // Pause/Resume music playing
+ if (IsKeyPressed(KEY_P))
+ {
+ pause = !pause;
+
+ if (pause) PauseMusicStream(xm);
+ else ResumeMusicStream(xm);
+ }
+
+ // Get timePlayed scaled to bar dimensions
+ timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2;
+
+ // Color circles animation
+ for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
{
circles[i].alpha += circles[i].speed;
circles[i].radius += circles[i].speed*10.0f;
@@ -88,11 +111,6 @@ int main()
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
}
}
-
- // Get timePlayed scaled to bar dimensions
- timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2;
-
- UpdateMusicStream(xm); // Update music buffer with new stream data
//----------------------------------------------------------------------------------
// Draw