diff options
| author | victorfisac <[email protected]> | 2016-10-06 20:57:31 +0200 |
|---|---|---|
| committer | victorfisac <[email protected]> | 2016-10-06 20:57:31 +0200 |
| commit | 2a158c47955d2d849e939152e0c174b02c500104 (patch) | |
| tree | fbf515597add99255f0e980d7a12ea33a3aa5585 /games/raylib_demo/raylib_demo.c | |
| parent | 3e1321ac24743cf3df1c2bb923023f9c222aa250 (diff) | |
| parent | db6538859cd2fabb44f1f29cd87f5b498ca0c2c8 (diff) | |
| download | raylib-2a158c47955d2d849e939152e0c174b02c500104.tar.gz raylib-2a158c47955d2d849e939152e0c174b02c500104.zip | |
Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
Diffstat (limited to 'games/raylib_demo/raylib_demo.c')
| -rw-r--r-- | games/raylib_demo/raylib_demo.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/games/raylib_demo/raylib_demo.c b/games/raylib_demo/raylib_demo.c index 22213b46..722d8ce6 100644 --- a/games/raylib_demo/raylib_demo.c +++ b/games/raylib_demo/raylib_demo.c @@ -123,6 +123,8 @@ Model cat; Sound fxWav; Sound fxOgg; +Music music; + Vector2 soundBallsPosition[MAX_BALLS]; Color soundBallsColor[MAX_BALLS]; bool soundBallsActive[MAX_BALLS]; @@ -203,11 +205,13 @@ int main() catTexture = LoadTexture("resources/catsham.png"); // Load model texture cat = LoadModel("resources/cat.obj"); // Load OBJ model - cat.material.texDiffuse = texture; // Set cat model diffuse texture + cat.material.texDiffuse = catTexture; // Set cat model diffuse texture fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file + music = LoadMusicStream("resources/audio/guitar_noodling.ogg"); // Load music + for (int i = 0; i < MAX_BALLS; i++) { soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) }; @@ -267,6 +271,8 @@ int main() UnloadSound(fxWav); UnloadSound(fxOgg); + + UnloadMusicStream(music); CloseAudioDevice(); @@ -464,11 +470,11 @@ void UpdateDrawOneFrame(void) if (selectedModule == AUDIO) { - if (IsKeyPressed(KEY_SPACE) && !MusicIsPlaying()) PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream + if (IsKeyPressed(KEY_SPACE) && !IsMusicPlaying(music)) PlayMusicStream(music); // Play music stream if (IsKeyPressed('S')) { - StopMusicStream(); + StopMusicStream(music); timePlayed = 0.0f; for (int i = 0; i < MAX_BALLS; i++) @@ -482,9 +488,11 @@ void UpdateDrawOneFrame(void) } } - if (MusicIsPlaying()) + if (IsMusicPlaying(music)) { - timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4; + UpdateMusicStream(music); + + timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4; if ((framesCounter%10) == 0) { @@ -842,7 +850,7 @@ void UpdateDrawOneFrame(void) DrawRectangle(150, 390, 400, 12, LIGHTGRAY); DrawRectangle(150, 390, (int)timePlayed, 12, MAROON); - if (MusicIsPlaying()) + if (IsMusicPlaying(music)) { DrawText("PRESS 'S' to STOP PLAYING MUSIC", 165, 425, 20, GRAY); |
