summaryrefslogtreecommitdiffhomepage
path: root/examples/src/audio/audio_module_playing.c
diff options
context:
space:
mode:
authorRay <[email protected]>2019-05-20 16:40:30 +0200
committerRay <[email protected]>2019-05-20 16:40:30 +0200
commit3d7d174c70b2d00fd879ade64c5085d4ff34d4aa (patch)
tree3b690948f186f855aa2ee8bab312b3ca28a56200 /examples/src/audio/audio_module_playing.c
parent0b56b996bd053ec875c229e9793f7806b666839c (diff)
downloadraylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.tar.gz
raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.zip
Review and recompile ALL examples
Diffstat (limited to 'examples/src/audio/audio_module_playing.c')
-rw-r--r--examples/src/audio/audio_module_playing.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/examples/src/audio/audio_module_playing.c b/examples/src/audio/audio_module_playing.c
index 54bfa3d..4aebd1e 100644
--- a/examples/src/audio/audio_module_playing.c
+++ b/examples/src/audio/audio_module_playing.c
@@ -23,25 +23,25 @@ typedef struct {
Color color;
} CircleWave;
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ const int screenWidth = 800;
+ const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
-
+
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
InitAudioDevice(); // Initialize audio device
-
+
Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
-
+
// Creates ome circles for visual effect
CircleWave circles[MAX_CIRCLES];
-
+
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{
circles[i].alpha = 0.0f;
@@ -53,7 +53,7 @@ int main()
}
Music xm = LoadMusicStream("resources/chiptun1.mod");
-
+
PlayMusicStream(xm);
float timePlayed = 0.0f;
@@ -68,34 +68,34 @@ int main()
// Update
//----------------------------------------------------------------------------------
UpdateMusicStream(xm); // Update music buffer with new stream data
-
+
// Restart music playing (stop and play)
- if (IsKeyPressed(KEY_SPACE))
+ if (IsKeyPressed(KEY_SPACE))
{
StopMusicStream(xm);
PlayMusicStream(xm);
}
-
- // Pause/Resume music playing
+
+ // 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);
-
+
// 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;
-
+
if (circles[i].alpha > 1.0f) circles[i].speed *= -1;
-
+
if (circles[i].alpha <= 0.0f)
{
circles[i].alpha = 0.0f;
@@ -113,12 +113,12 @@ int main()
BeginDrawing();
ClearBackground(RAYWHITE);
-
+
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha));
}
-
+
// Draw time bar
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY);
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
@@ -131,7 +131,7 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadMusicStream(xm); // Unload music stream buffers from RAM
-
+
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
CloseWindow(); // Close window and OpenGL context