summaryrefslogtreecommitdiffhomepage
path: root/examples/audio/audio_module_playing.c
diff options
context:
space:
mode:
authorRay <[email protected]>2019-05-20 16:36:42 +0200
committerRay <[email protected]>2019-05-20 16:36:42 +0200
commitb525039e0ab8bcaa2fd6bde34c72a6405f88ae49 (patch)
tree08f1c79bfe693643564ed78202c9474b7eb83a79 /examples/audio/audio_module_playing.c
parenta43a7980a30a52462956b23f2473e8ef8f38d1fb (diff)
downloadraylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.tar.gz
raylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.zip
Review ALL examples
Diffstat (limited to 'examples/audio/audio_module_playing.c')
-rw-r--r--examples/audio/audio_module_playing.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/examples/audio/audio_module_playing.c b/examples/audio/audio_module_playing.c
index 54bfa3d2..4aebd1e6 100644
--- a/examples/audio/audio_module_playing.c
+++ b/examples/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