Updated games to latest raylib version

Updated to new audio system
This commit is contained in:
raysan5
2016-08-11 12:08:41 +02:00
parent 289e04a62a
commit 29f14186c1
9 changed files with 93 additions and 52 deletions

View File

@ -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);