// Update and draw game frame void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- if (!onTransition) { if (player.dead) { framesCounter++; if (framesCounter > 80) { framesCounter = 0; player.dead = false; player.numLifes = 4; TransitionToScreen(TITLE); } } switch(currentScreen) { case LOGO: { UpdateLogoScreen(); if (FinishLogoScreen()) ChangeToScreen(LOGO_RL); } break; case LOGO_RL: { rlUpdateLogoScreen(); if (rlFinishLogoScreen()) TransitionToScreen(TITLE); } break; case TITLE: { UpdateTitleScreen(); if (FinishTitleScreen() == 1) TransitionToScreen(ATTIC); } break; case ATTIC: { UpdateAtticScreen(); if (FinishAtticScreen() == 1) TransitionToScreen(AISLE01); } break; case AISLE01: { UpdateAisle01Screen(); if (FinishAisle01Screen() == 1) TransitionToScreen(BATHROOM); else if(FinishAisle01Screen() == 2) TransitionToScreen(KITCHEN); else if(FinishAisle01Screen() == 3) TransitionToScreen(LIVINGROOM); } break; case BATHROOM: { UpdateBathroomScreen(); if (FinishBathroomScreen() == 1) TransitionToScreen(AISLE01); } break; case LIVINGROOM: { UpdateLivingroomScreen(); if (FinishLivingroomScreen() == 1) TransitionToScreen(AISLE01); else if(FinishLivingroomScreen() == 2)TransitionToScreen(AISLE02); } break; case AISLE02: { UpdateAisle02Screen(); if (FinishAisle02Screen() == 1) TransitionToScreen(KITCHEN); } break; case KITCHEN: { UpdateKitchenScreen(); if (FinishKitchenScreen() == 1) TransitionToScreen(ARMORY); else if(FinishKitchenScreen() == 2)TransitionToScreen(AISLE02); } break; case ARMORY: { UpdateArmoryScreen(); if(FinishArmoryScreen() == 1) TransitionToScreen(ENDING); else if(FinishArmoryScreen() == 2) TransitionToScreen(KITCHEN); } break; case ENDING: { UpdateEndingScreen(); if (FinishEndingScreen()) TransitionToScreen(TITLE); } break; default: break; } } else { // Update transition (fade-in, fade-out) UpdateTransition(); } UpdateMusicStream(music); //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); switch(currentScreen) { case LOGO: DrawLogoScreen(); break; case LOGO_RL: rlDrawLogoScreen(); break; case TITLE: DrawTitleScreen(); break; case ATTIC: DrawAtticScreen(); break; case AISLE01: DrawAisle01Screen();break; case AISLE02: DrawAisle02Screen();break; case BATHROOM: DrawBathroomScreen();break; case LIVINGROOM: DrawLivingroomScreen();break; case KITCHEN: DrawKitchenScreen();break; case ARMORY: DrawArmoryScreen();break; case ENDING: DrawEndingScreen(); 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(); //---------------------------------------------------------------------------------- }