You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.1 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Advance Game template
  4. *
  5. * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
  6. *
  7. * Copyright (c) 2014 Ramon Santamaria (@raysan5)
  8. *
  9. * This software is provided "as-is", without any express or implied warranty. In no event
  10. * will the authors be held liable for any damages arising from the use of this software.
  11. *
  12. * Permission is granted to anyone to use this software for any purpose, including commercial
  13. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not claim that you
  16. * wrote the original software. If you use this software in a product, an acknowledgment
  17. * in the product documentation would be appreciated but is not required.
  18. *
  19. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  20. * as being the original software.
  21. *
  22. * 3. This notice may not be removed or altered from any source distribution.
  23. *
  24. **********************************************************************************************/
  25. #include "raylib.h"
  26. #include "screens.h"
  27. //----------------------------------------------------------------------------------
  28. // Global Variables Definition (local to this module)
  29. //----------------------------------------------------------------------------------
  30. // Logo screen global variables
  31. static int framesCounter = 0;
  32. static int finishScreen;
  33. static Texture2D logo;
  34. static float logoAlpha = 0;
  35. static int state = 0;
  36. //----------------------------------------------------------------------------------
  37. // Logo Screen Functions Definition
  38. //----------------------------------------------------------------------------------
  39. // Logo Screen Initialization logic
  40. void InitLogoScreen(void)
  41. {
  42. // Initialize LOGO screen variables here!
  43. finishScreen = 0;
  44. logo = LoadTexture("resources/textures/skully_logo.png");
  45. }
  46. // Logo Screen Update logic
  47. void UpdateLogoScreen(void)
  48. {
  49. // Update LOGO screen variables here!
  50. if (state == 0)
  51. {
  52. logoAlpha += 0.04f;
  53. if (logoAlpha >= 1.0f) state = 1;
  54. }
  55. else if (state == 1)
  56. {
  57. framesCounter++;
  58. if (framesCounter > 180) state = 2;
  59. }
  60. else if (state == 2)
  61. {
  62. logoAlpha -= 0.04f;
  63. if (logoAlpha <= 0.0f)
  64. {
  65. framesCounter = 0;
  66. state = 3;
  67. }
  68. }
  69. else if (state == 3)
  70. {
  71. finishScreen = 1;
  72. }
  73. }
  74. // Logo Screen Draw logic
  75. void DrawLogoScreen(void)
  76. {
  77. DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RAYWHITE);
  78. DrawTexture(logo, GetScreenWidth()/2 - logo.width/2, 130, Fade(WHITE, logoAlpha));
  79. DrawText("GRAY TEAM", 340, 450, 100, Fade(DARKGRAY, logoAlpha));
  80. }
  81. // Logo Screen Unload logic
  82. void UnloadLogoScreen(void)
  83. {
  84. // Unload LOGO screen variables here!
  85. UnloadTexture(logo);
  86. }
  87. // Logo Screen should finish?
  88. int FinishLogoScreen(void)
  89. {
  90. return finishScreen;
  91. }