diff options
Diffstat (limited to 'games/transmission/screens/screen_logo.c')
| -rw-r--r-- | games/transmission/screens/screen_logo.c | 201 |
1 files changed, 172 insertions, 29 deletions
diff --git a/games/transmission/screens/screen_logo.c b/games/transmission/screens/screen_logo.c index dc016423..80c99809 100644 --- a/games/transmission/screens/screen_logo.c +++ b/games/transmission/screens/screen_logo.c @@ -26,19 +26,32 @@ #include "raylib.h" #include "screens.h" +#define LOGO_RECS_SIDE 16 + //---------------------------------------------------------------------------------- // Global Variables Definition (local to this module) //---------------------------------------------------------------------------------- // Logo screen global variables -static int framesCounter; -static int finishScreen; +static int framesCounter = 0; +static int finishScreen = 0; + +static int logoPositionX = 0; +static int logoPositionY = 0; + +static int lettersCount = 0; + +static int topSideRecWidth = 0; +static int leftSideRecHeight = 0; -static Texture2D logoCW; +static int bottomSideRecWidth = 0; +static int rightSideRecHeight = 0; -static float fadeValue; -static int showLogoFrames; -static bool fadeOut; +static char raylib[8] = { 0 }; // raylib text array, max 8 letters +static int state = 0; // Tracking animation states (State Machine) +static float alpha = 1.0f; // Useful for fading + +static Texture2D texLogoCW = { 0 }; // Cinamon Works texture //---------------------------------------------------------------------------------- // Logo Screen Functions Definition @@ -47,53 +60,183 @@ static bool fadeOut; // Logo Screen Initialization logic void InitLogoScreen(void) { - framesCounter = 0; + // Initialize LOGO screen variables here! finishScreen = 0; + framesCounter = 0; + lettersCount = 0; + + logoPositionX = GetScreenWidth()/2 - 128; + logoPositionY = GetScreenHeight()/2 - 128; - logoCW = LoadTexture("resources/textures/cw_logo.png"); + topSideRecWidth = LOGO_RECS_SIDE; + leftSideRecHeight = LOGO_RECS_SIDE; + bottomSideRecWidth = LOGO_RECS_SIDE; + rightSideRecHeight = LOGO_RECS_SIDE; - showLogoFrames = 60; - fadeValue = 0; + for (int i = 0; i < 8; i++) raylib[i] = '\0'; - fadeOut = false; + state = 0; + alpha = 1.0f; + + texLogoCW = LoadTexture("resources/textures/cw_logo.png"); } // Logo Screen Update logic void UpdateLogoScreen(void) { - if (!fadeOut) - { - fadeValue += 0.02f; - if (fadeValue > 1.01f) + // Update LOGO screen variables here! + if (state == 0) // State 0: Small box blinking + { + framesCounter++; + + if (framesCounter == 80) + { + state = 1; + framesCounter = 0; // Reset counter... will be used later... + } + } + else if (state == 1) // State 1: Top and left bars growing + { + topSideRecWidth += 8; + leftSideRecHeight += 8; + + if (topSideRecWidth == 256) state = 2; + } + else if (state == 2) // State 2: Bottom and right bars growing + { + bottomSideRecWidth += 8; + rightSideRecHeight += 8; + + if (bottomSideRecWidth == 256) state = 3; + } + else if (state == 3) // State 3: Letters appearing (one by one) + { + framesCounter++; + + if (framesCounter/10) // Every 12 frames, one more letter! + { + lettersCount++; + framesCounter = 0; + } + + switch (lettersCount) { - fadeValue = 1.0f; - framesCounter++; - - if ((framesCounter%showLogoFrames) == 0) + case 1: raylib[0] = 'r'; break; + case 2: raylib[1] = 'a'; break; + case 3: raylib[2] = 'y'; break; + case 4: raylib[3] = 'l'; break; + case 5: raylib[4] = 'i'; break; + case 6: raylib[5] = 'b'; break; + default: break; + } + + // When all letters have appeared... + if (lettersCount >= 10) + { + state = 4; + framesCounter = 0; + } + } + else if (state == 4) + { + framesCounter++; + + if (framesCounter > 100) + { + alpha -= 0.02f; + + if (alpha <= 0.0f) { - fadeOut = true; - finishScreen = true; - } - } - } - - if (IsKeyPressed(KEY_ENTER)) finishScreen = true; + alpha = 0.0f; + framesCounter = 0; + state = 5; + } + } + } + else if (state == 5) + { + alpha += 0.02f; + if (alpha >= 1.0f) alpha = 1.0f; + + framesCounter++; + if (framesCounter > 200) + { + framesCounter = 0; + state = 6; + } + } + else if (state == 6) + { + alpha -= 0.02f; + if (alpha >= 1.0f) alpha = 1.0f; + + framesCounter++; + if (framesCounter > 100) + { + framesCounter = 0; + finishScreen = 1; + } + } } // Logo Screen Draw logic void DrawLogoScreen(void) { - DrawTexture(logoCW, GetScreenWidth()/2 - logoCW.width/2, GetScreenHeight()/2 - logoCW.height/2, Fade(WHITE, fadeValue)); + if (state == 0) + { + if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); + } + else if (state == 1) + { + DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); + DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); + } + else if (state == 2) + { + DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); + DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); + + DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); + DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); + } + else if (state == 3) + { + DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); + DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); + + DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); + DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); + + DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); + + DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); + } + else if (state == 4) + { + DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); + DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); + + DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); + DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); + + DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); + + DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); + + if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); + } + else if ((state == 5) || (state == 6)) DrawTexture(texLogoCW, GetScreenWidth()/2 - texLogoCW.width/2, GetScreenHeight()/2 - texLogoCW.height/2, Fade(WHITE, alpha)); } // Logo Screen Unload logic void UnloadLogoScreen(void) { - UnloadTexture(logoCW); + // Unload LOGO screen variables here! + UnloadTexture(texLogoCW); } // Logo Screen should finish? int FinishLogoScreen(void) { return finishScreen; -}
\ No newline at end of file +} |
