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.

101 lines
2.9 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Advance Game template
  4. *
  5. * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
  6. *
  7. * Copyright (c) 2014-2018 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;
  32. static int finishScreen;
  33. static Texture2D logoCW;
  34. static float fadeValue;
  35. static int showLogoFrames;
  36. static bool fadeOut;
  37. //----------------------------------------------------------------------------------
  38. // Logo Screen Functions Definition
  39. //----------------------------------------------------------------------------------
  40. // Logo Screen Initialization logic
  41. void InitLogoScreen(void)
  42. {
  43. framesCounter = 0;
  44. finishScreen = 0;
  45. logoCW = LoadTexture("resources/textures/cw_logo.png");
  46. showLogoFrames = 60;
  47. fadeValue = 0;
  48. fadeOut = false;
  49. }
  50. // Logo Screen Update logic
  51. void UpdateLogoScreen(void)
  52. {
  53. if(!fadeOut)
  54. {
  55. fadeValue += 0.02f;
  56. if(fadeValue > 1.01f)
  57. {
  58. fadeValue = 1.0f;
  59. framesCounter++;
  60. if(framesCounter % showLogoFrames == 0)
  61. {
  62. fadeOut = true;
  63. finishScreen = true;
  64. }
  65. }
  66. }
  67. if(IsKeyPressed(KEY_ENTER))
  68. {
  69. finishScreen = true;
  70. }
  71. }
  72. // Logo Screen Draw logic
  73. void DrawLogoScreen(void)
  74. {
  75. DrawTexture(logoCW, GetScreenWidth()/2 - logoCW.width/2, GetScreenHeight()/2 - logoCW.height/2, Fade(WHITE, fadeValue));
  76. }
  77. // Logo Screen Unload logic
  78. void UnloadLogoScreen(void)
  79. {
  80. UnloadTexture(logoCW);
  81. }
  82. // Logo Screen should finish?
  83. int FinishLogoScreen(void)
  84. {
  85. return finishScreen;
  86. }