Пример #1
0
void UpdateTransition(void)
{
    if (!transFadeOut)
    {
        transAlpha += 0.05f;

        if (transAlpha >= 1.0)
        {
            transAlpha = 1.0;
        
            switch (transFromScreen)
            {
                case LOGO_RL: rlUnloadLogoScreen(); break;
                case TITLE: UnloadTitleScreen(); break;
                case GAMEPLAY: UnloadGameplayScreen(); break;
                default: break;
            }
            
            switch (transToScreen)
            {
                case LOGO_RL:
                {
                    rlInitLogoScreen();
                    currentScreen = LOGO_RL;
                } break;
                case TITLE: 
                {
                    InitTitleScreen();
                    currentScreen = TITLE;                  
                } break;
                case GAMEPLAY:
                {
                    InitGameplayScreen(); 
                    currentScreen = GAMEPLAY;
                } break;
                default: break;
            }
            
            transFadeOut = true;
        }
    }
    else  // Transition fade out logic
    {
        transAlpha -= 0.05f;
        
        if (transAlpha <= 0)
        {
            transAlpha = 0;
            transFadeOut = false;
            onTransition = false;
            transFromScreen = -1;
            transToScreen = -1;
        }
    }
}
Пример #2
0
// Update transition effect
static void UpdateTransition(void)
{
    if (!transFadeOut)
    {
        transAlpha += 0.05f;
        
        // 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 ((int)transAlpha >= 1)
        {
            transAlpha = 1.0f;
        
            // Unload current screen
            switch (transFromScreen)
            {
                case LOGO: UnloadLogoScreen(); break;
                case TITLE: UnloadTitleScreen(); break;
                case GAMEPLAY: UnloadGameplayScreen(); break;
                case ENDING: UnloadEndingScreen(); break;
                default: break;
            }
            
            // Load next screen
            switch (transToScreen)
            {
                case LOGO: InitLogoScreen(); break;
                case TITLE: InitTitleScreen(); break;
                case GAMEPLAY: InitGameplayScreen(); break;
                case ENDING: InitEndingScreen(); break;
                default: break;
            }
            
            currentScreen = transToScreen;
            
            // Activate fade out effect to next loaded screen
            transFadeOut = true;
        }
    }
    else  // Transition fade out logic
    {
        transAlpha -= 0.05f;
        
        if ((int)transAlpha <= 0)
        {
            transAlpha = 0.0f;
            transFadeOut = false;
            onTransition = false;
            transFromScreen = -1;
            transToScreen = -1;
        }
    }
}
Пример #3
0
void ChangeToScreen(int screen)
{
    switch (currentScreen)
    {
        case LOGO_RL: rlUnloadLogoScreen(); break;
        case TITLE: UnloadTitleScreen(); break;
        case GAMEPLAY: UnloadGameplayScreen(); break;
        default: break;
    }
    
    switch (screen)
    {
        case LOGO_RL: rlInitLogoScreen(); break;
        case TITLE: InitTitleScreen(); break;
        case GAMEPLAY: InitGameplayScreen(); break;
        default: break;
    }
    
    currentScreen = screen;
}
Пример #4
0
// Change to next screen, no transition
static void ChangeToScreen(int screen)
{
    // Unload current screen
    switch (currentScreen)
    {
        case LOGO: UnloadLogoScreen(); break;
        case TITLE: UnloadTitleScreen(); break;
        case GAMEPLAY: UnloadGameplayScreen(); break;
        case ENDING: UnloadEndingScreen(); break;
        default: break;
    }
    
    // Init next screen
    switch (screen)
    {
        case LOGO: InitLogoScreen(); break;
        case TITLE: InitTitleScreen(); break;
        case GAMEPLAY: InitGameplayScreen(); break;
        case ENDING: InitEndingScreen(); break;
        default: break;
    }
    
    currentScreen = screen;
}
Пример #5
0
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
int main(void) 
{
	// Initialization (Note windowTitle is unused on Android)
	//---------------------------------------------------------
    InitWindow(screenWidth, screenHeight, "KOALA SEASONS");

    // Load global data here (assets that must be available in all screens, i.e. fonts)
    font = LoadFont("resources/graphics/mainfont.png");

    atlas01 = LoadTexture("resources/graphics/atlas01.png");
    atlas02 = LoadTexture("resources/graphics/atlas02.png");
    
#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_ANDROID)
    colorBlend = LoadShader("resources/shaders/glsl100/base.vs", "resources/shaders/glsl100/blend_color.fs");
#else
    colorBlend = LoadShader("resources/shaders/glsl330/base.vs", "resources/shaders/glsl330/blend_color.fs");
#endif

    InitAudioDevice();
    
    // Load sounds data
    fxJump = LoadSound("resources/audio/jump.ogg");
    fxDash = LoadSound("resources/audio/dash.ogg");
    fxEatLeaves = LoadSound("resources/audio/eat_leaves.ogg");
    fxHitResin = LoadSound("resources/audio/resin_hit.ogg");
    fxWind = LoadSound("resources/audio/wind_sound.ogg");
    fxDieSnake = LoadSound("resources/audio/snake_die.ogg");
    fxDieDingo = LoadSound("resources/audio/dingo_die.ogg");
    fxDieOwl = LoadSound("resources/audio/owl_die.ogg");
    
    
    music = LoadMusicStream("resources/audio/jngl.xm");
    PlayMusicStream(music);
    SetMusicVolume(music, 1.0f);

    // Define and init first screen
    // NOTE: currentScreen is defined in screens.h as a global variable
    currentScreen = TITLE;

    InitLogoScreen();
    //InitOptionsScreen();
    InitTitleScreen();
    InitGameplayScreen();
    InitEndingScreen();

#if defined(PLATFORM_WEB)
    emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
    SetTargetFPS(60);   // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------
    
    // Main game loop
    while (!WindowShouldClose()) UpdateDrawFrame();
#endif

    // De-Initialization
    //--------------------------------------------------------------------------------------
    UnloadEndingScreen();
    UnloadTitleScreen();
    UnloadGameplayScreen();
    UnloadLogoScreen();
    
    UnloadTexture(atlas01);
    UnloadTexture(atlas02);
    UnloadFont(font);
    
    UnloadShader(colorBlend);   // Unload color overlay blending shader
    
    UnloadSound(fxJump);
    UnloadSound(fxDash);
    UnloadSound(fxEatLeaves);
    UnloadSound(fxHitResin);
    UnloadSound(fxWind);
    UnloadSound(fxDieSnake);
    UnloadSound(fxDieDingo);
    UnloadSound(fxDieOwl);
    
    UnloadMusicStream(music);
    
    CloseAudioDevice();         // Close audio device

    CloseWindow();              // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}
Пример #6
0
// 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();
    //----------------------------------------------------------------------------------
}