From 5a230659ef39c6eb3bdb5412ca6e1bfc9eeda98e Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 4 Apr 2017 00:21:52 +0200 Subject: [PATCH] Working in random crash... Related to UpdateMusicStream(), in stb_vorbis --- games/wave_collector/Makefile | 8 +-- .../wave_collector/screens/screen_gameplay.c | 1 + games/wave_collector/wave_collector.c | 61 ++++++++----------- 3 files changed, 29 insertions(+), 41 deletions(-) diff --git a/games/wave_collector/Makefile b/games/wave_collector/Makefile index 5b4ee0bf..186598f1 100644 --- a/games/wave_collector/Makefile +++ b/games/wave_collector/Makefile @@ -94,9 +94,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) INCLUDES = -I. -I../../src -IC:/raylib/raylib/src # external libraries headers # GLFW3 - INCLUDES += -I../../external/glfw3/include + INCLUDES += -I../../external/glfw3/include # OpenAL Soft - INCLUDES += -I../../external/openal_soft/include + INCLUDES += -I../../external/openal_soft/include endif endif @@ -115,9 +115,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif # external libraries to link with # GLFW3 - LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) + LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) ifneq ($(PLATFORM_OS),OSX) - # OpenAL Soft + # OpenAL Soft LFLAGS += -L../../external/openal_soft/lib/$(LIBPATH) endif endif diff --git a/games/wave_collector/screens/screen_gameplay.c b/games/wave_collector/screens/screen_gameplay.c index 4019e64c..cbedf74c 100644 --- a/games/wave_collector/screens/screen_gameplay.c +++ b/games/wave_collector/screens/screen_gameplay.c @@ -210,6 +210,7 @@ void InitGameplayScreen(void) // Load and start playing music // NOTE: Music is loaded in main code base + StopMusicStream(music); PlayMusicStream(music); } diff --git a/games/wave_collector/wave_collector.c b/games/wave_collector/wave_collector.c index 53b4b713..bd10ecf2 100644 --- a/games/wave_collector/wave_collector.c +++ b/games/wave_collector/wave_collector.c @@ -42,14 +42,13 @@ static int transToScreen = -1; //---------------------------------------------------------------------------------- // Local Functions Declaration //---------------------------------------------------------------------------------- +static void ChangeToScreen(int screen); // No transition effect + static void TransitionToScreen(int screen); -static void ChangeToScreen(int screen); // No transition effect static void UpdateTransition(void); static void DrawTransition(void); -static void UpdateDrawFrame(void); // Update and Draw one frame - -//static const char *GetExtension(const char *fileName); +static void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main entry point @@ -64,8 +63,8 @@ int main(int argc, char *argv[]) sampleFilename = (char *)malloc(256); if (argc > 1) { - if ((strcmp(GetExtension(argv[1]), "ogg") == 0) || - (strcmp(GetExtension(argv[1]), "wav") == 0)) + if ((IsFileExtension(argv[1], ".ogg")) || + (IsFileExtension(argv[1], ".wav"))) { strcpy(sampleFilename, argv[1]); } @@ -105,6 +104,8 @@ int main(int argc, char *argv[]) // De-Initialization //-------------------------------------------------------------------------------------- + StopMusicStream(music); + switch (currentScreen) { case LOGO: UnloadLogoScreen(); break; @@ -130,18 +131,8 @@ int main(int argc, char *argv[]) // Module specific Functions Definition //---------------------------------------------------------------------------------- -// Define transition to next screen -static void TransitionToScreen(int screen) -{ - onTransition = true; - transFadeOut = false; - transFromScreen = currentScreen; - transToScreen = screen; - transAlpha = 0.0f; -} - // Change to next screen, no transition -void ChangeToScreen(int screen) +static void ChangeToScreen(int screen) { // Unload current screen switch (currentScreen) @@ -166,8 +157,18 @@ void ChangeToScreen(int screen) currentScreen = screen; } +// Define transition to next screen +static void TransitionToScreen(int screen) +{ + onTransition = true; + transFadeOut = false; + transFromScreen = currentScreen; + transToScreen = screen; + transAlpha = 0.0f; +} + // Update transition effect -void UpdateTransition(void) +static void UpdateTransition(void) { if (!transFadeOut) { @@ -175,7 +176,7 @@ void UpdateTransition(void) // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f // For that reason we compare against 1.01f, to avoid last frame loading stop - if (transAlpha > 1.01f) + if ((int)transAlpha >= 1) { transAlpha = 1.0f; @@ -209,7 +210,7 @@ void UpdateTransition(void) { transAlpha -= 0.05f; - if (transAlpha <= 0.0f) + if ((int)transAlpha <= 0) { transAlpha = 0.0f; transFadeOut = false; @@ -221,13 +222,13 @@ void UpdateTransition(void) } // Draw transition effect (full-screen rectangle) -void DrawTransition(void) +static void DrawTransition(void) { DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, transAlpha)); } // Update and draw game frame -void UpdateDrawFrame(void) +static void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- @@ -291,20 +292,6 @@ void UpdateDrawFrame(void) // Draw full screen rectangle in front of everything if (onTransition) DrawTransition(); - //DrawFPS(10, 10); - EndDrawing(); //---------------------------------------------------------------------------------- -} - -/* -#if !defined(PLATFORM_WEB) -// Get the extension for a filename -static const char *GetExtension(const char *fileName) -{ - const char *dot = strrchr(fileName, '.'); - if (!dot || dot == fileName) return ""; - return (dot + 1); -} -#endif -*/ \ No newline at end of file +} \ No newline at end of file