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.

91 lines
3.0 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Advance Game template
  4. *
  5. * Title 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. // Title screen global variables
  31. static int framesCounter;
  32. static int finishScreen;
  33. static Texture2D title;
  34. static float titleAlpha = 0.0f;
  35. //----------------------------------------------------------------------------------
  36. // Title Screen Functions Definition
  37. //----------------------------------------------------------------------------------
  38. // Title Screen Initialization logic
  39. void InitTitleScreen(void)
  40. {
  41. // Initialize TITLE screen variables here!
  42. framesCounter = 0;
  43. finishScreen = 0;
  44. title = LoadTexture("resources/textures/title.png");
  45. }
  46. // Title Screen Update logic
  47. void UpdateTitleScreen(void)
  48. {
  49. // Update TITLE screen variables here!
  50. framesCounter++;
  51. titleAlpha += 0.005f;
  52. if (titleAlpha >= 1.0f) titleAlpha = 1.0f;
  53. // Press enter to change to ATTIC screen
  54. if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
  55. {
  56. finishScreen = 1;
  57. }
  58. }
  59. // Title Screen Draw logic
  60. void DrawTitleScreen(void)
  61. {
  62. //DrawText("TITLE SCREEN", 100, 100, 140, Fade(BLACK, titleAlpha));
  63. DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY);
  64. DrawTexture(title, GetScreenWidth()/2 - title.width/2, 20, Fade(WHITE, titleAlpha));
  65. if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER to START", 380, 545, 40, BLACK);
  66. }
  67. // Title Screen Unload logic
  68. void UnloadTitleScreen(void)
  69. {
  70. // Unload TITLE screen variables here!
  71. UnloadTexture(title);
  72. }
  73. // Title Screen should finish?
  74. int FinishTitleScreen(void)
  75. {
  76. return finishScreen;
  77. }