diff options
| author | raysan5 <raysan5@gmail.com> | 2016-08-11 12:08:41 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-08-11 12:08:41 +0200 |
| commit | 29f14186c1da2c73c6e0c94c8a744f163784e762 (patch) | |
| tree | 1b0af18634d79c6aaf4ef7bb6570db766c71b039 /games/raylib_demo | |
| parent | 289e04a62a64a6e82aa5da3397baaa7f48cc45ed (diff) | |
| download | raylib-29f14186c1da2c73c6e0c94c8a744f163784e762.tar.gz raylib-29f14186c1da2c73c6e0c94c8a744f163784e762.zip | |
Updated games to latest raylib version
Updated to new audio system
Diffstat (limited to 'games/raylib_demo')
| -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); |
