// Update and draw game frame void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- if (!onTransition) { switch(currentScreen) { case LOGO_RL: { rlUpdateLogoScreen(); if (rlFinishLogoScreen()) TransitionToScreen(TITLE); } break; case TITLE: { UpdateTitleScreen(); if (FinishTitleScreen() == 1) TransitionToScreen(GAMEPLAY); } break; case GAMEPLAY: { UpdateGameplayScreen(); if (FinishGameplayScreen() == 1) ChangeToScreen(LOGO_RL); else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); } break; default: break; } } else { // Update transition (fade-in, fade-out) UpdateTransition(); } UpdateMusicStream(); //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); switch(currentScreen) { case LOGO_RL: rlDrawLogoScreen(); break; case TITLE: DrawTitleScreen(); break; case GAMEPLAY: DrawGameplayScreen(); break; default: break; } if (onTransition) DrawTransition(); //DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- }
// Update and Draw one frame void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- if (!onTransition) { switch (currentScreen) { case LOGO: { UpdateLogoScreen(); if (FinishLogoScreen()) TransitionToScreen(TITLE); } break; case TITLE: { UpdateTitleScreen(); // NOTE: FinishTitleScreen() return an int defining the screen to jump to if (FinishTitleScreen() == 1) { UnloadTitleScreen(); //currentScreen = OPTIONS; //InitOptionsScreen(); } else if (FinishTitleScreen() == 2) { UnloadTitleScreen(); InitGameplayScreen(); TransitionToScreen(GAMEPLAY); } } break; case GAMEPLAY: { UpdateGameplayScreen(); if (FinishGameplayScreen()) { UnloadGameplayScreen(); InitEndingScreen(); TransitionToScreen(ENDING); } } break; case ENDING: { UpdateEndingScreen(); if (FinishEndingScreen()) { UnloadEndingScreen(); InitGameplayScreen(); TransitionToScreen(GAMEPLAY); } } break; default: break; } } else UpdateTransition(); UpdateMusicStream(music); //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(WHITE); switch (currentScreen) { case LOGO: DrawLogoScreen(); break; case TITLE: DrawTitleScreen(); break; case GAMEPLAY: DrawGameplayScreen(); break; case ENDING: DrawEndingScreen(); break; default: break; } if (onTransition) DrawTransition(); DrawFPS(20, GetScreenHeight() - 30); DrawRectangle(GetScreenWidth() - 200, GetScreenHeight() - 50, 200, 40, Fade(WHITE, 0.6f)); DrawText("ALPHA VERSION", GetScreenWidth() - 180, GetScreenHeight() - 40, 20, DARKGRAY); EndDrawing(); //---------------------------------------------------------------------------------- }
// Update and draw game frame static void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- if (!onTransition) { switch(currentScreen) { case LOGO: { UpdateLogoScreen(); if (FinishLogoScreen()) TransitionToScreen(TITLE); } break; case TITLE: { UpdateTitleScreen(); if (FinishTitleScreen() == 1) TransitionToScreen(GAMEPLAY); } break; case GAMEPLAY: { UpdateGameplayScreen(); if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING); //else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); } break; case ENDING: { UpdateEndingScreen(); if (FinishEndingScreen() == 1) TransitionToScreen(TITLE); } break; default: break; } } else UpdateTransition(); // Update transition (fade-in, fade-out) // TODO: Review! It breaks the game... issues with audio buffering... if (currentScreen != ENDING) UpdateMusicStream(music); //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); switch(currentScreen) { case LOGO: DrawLogoScreen(); break; case TITLE: DrawTitleScreen(); break; case GAMEPLAY: DrawGameplayScreen(); break; case ENDING: DrawEndingScreen(); break; default: break; } // Draw full screen rectangle in front of everything if (onTransition) DrawTransition(); EndDrawing(); //---------------------------------------------------------------------------------- }