Browse Source

Working in random crash...

Related to UpdateMusicStream(), in stb_vorbis
pull/208/merge
Ray 7 years ago
parent
commit
5a230659ef
3 changed files with 29 additions and 41 deletions
  1. +4
    -4
      games/wave_collector/Makefile
  2. +1
    -0
      games/wave_collector/screens/screen_gameplay.c
  3. +24
    -37
      games/wave_collector/wave_collector.c

+ 4
- 4
games/wave_collector/Makefile View File

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

+ 1
- 0
games/wave_collector/screens/screen_gameplay.c View File

@ -210,6 +210,7 @@ void InitGameplayScreen(void)
// Load and start playing music
// NOTE: Music is loaded in main code base
StopMusicStream(music);
PlayMusicStream(music);
}

+ 24
- 37
games/wave_collector/wave_collector.c View File

@ -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 (n">transAlpha > 1.01f)
if (p">(int)transAlpha >= 1)
{
transAlpha = 1.0f;
@ -209,7 +210,7 @@ void UpdateTransition(void)
{
transAlpha -= 0.05f;
if (transAlpha <= f">0.0f)
if (p">(int)transAlpha <= i">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
*/
}

Loading…
Cancel
Save