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.

111 lines
3.7 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 texBackground;
  34. static Texture2D texTitle;
  35. static Texture2D texLogo;
  36. static float titleAlpha = 0.0f;
  37. static Sound fxStart;
  38. //----------------------------------------------------------------------------------
  39. // Title Screen Functions Definition
  40. //----------------------------------------------------------------------------------
  41. // Title Screen Initialization logic
  42. void InitTitleScreen(void)
  43. {
  44. // Initialize TITLE screen variables here!
  45. framesCounter = 0;
  46. finishScreen = 0;
  47. texBackground = LoadTexture("resources/textures/background_title.png");
  48. texTitle = LoadTexture("resources/textures/title.png");
  49. texLogo = LoadTexture("resources/textures/logo_raylib.png");
  50. fxStart = LoadSound("resources/audio/start.wav");
  51. }
  52. // Title Screen Update logic
  53. void UpdateTitleScreen(void)
  54. {
  55. // Update TITLE screen variables here!
  56. framesCounter++;
  57. titleAlpha += 0.005f;
  58. if (titleAlpha >= 1.0f) titleAlpha = 1.0f;
  59. // Press enter to change to ATTIC screen
  60. if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
  61. {
  62. PlaySound(fxStart);
  63. StopMusicStream(music);
  64. finishScreen = 1;
  65. }
  66. }
  67. // Title Screen Draw logic
  68. void DrawTitleScreen(void)
  69. {
  70. DrawTexture(texBackground, 0, 0, WHITE);
  71. DrawTexture(texTitle, GetScreenWidth()/2 - texTitle.width/2, -25, Fade(WHITE, titleAlpha));
  72. DrawRectangle(0, GetScreenHeight() - 70, 560, 40, Fade(RAYWHITE, 0.8f));
  73. DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 36, GetScreenHeight() - 60, 20, DARKBLUE);
  74. DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY);
  75. DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE);
  76. if ((framesCounter > 160) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to start", (Vector2){ 325, 500 }, font.baseSize, 0, SKYBLUE);
  77. }
  78. // Title Screen Unload logic
  79. void UnloadTitleScreen(void)
  80. {
  81. // Unload TITLE screen variables here!
  82. UnloadTexture(texBackground);
  83. UnloadTexture(texTitle);
  84. UnloadTexture(texLogo);
  85. UnloadSound(fxStart);
  86. }
  87. // Title Screen should finish?
  88. int FinishTitleScreen(void)
  89. {
  90. return finishScreen;
  91. }