Working in random crash...
Related to UpdateMusicStream(), in stb_vorbis
This commit is contained in:
parent
c3b8a41f95
commit
5a230659ef
@ -210,6 +210,7 @@ void InitGameplayScreen(void)
|
||||
|
||||
// Load and start playing music
|
||||
// NOTE: Music is loaded in main code base
|
||||
StopMusicStream(music);
|
||||
PlayMusicStream(music);
|
||||
}
|
||||
|
||||
|
@ -42,15 +42,14 @@ static int transToScreen = -1;
|
||||
//----------------------------------------------------------------------------------
|
||||
// Local Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
static void TransitionToScreen(int screen);
|
||||
static void ChangeToScreen(int screen); // No transition effect
|
||||
|
||||
static void TransitionToScreen(int screen);
|
||||
static void UpdateTransition(void);
|
||||
static void DrawTransition(void);
|
||||
|
||||
static void UpdateDrawFrame(void); // Update and Draw one frame
|
||||
|
||||
//static const char *GetExtension(const char *fileName);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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
|
||||
*/
|
Loading…
Reference in New Issue
Block a user