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.

110 line
3.9 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Advance Game template
  4. *
  5. * Ending 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. // Ending screen global variables
  31. static int framesCounter;
  32. static int finishScreen;
  33. static Texture2D texBackground;
  34. static Texture2D texWin;
  35. static Texture2D texLose;
  36. static Texture2D texLogo;
  37. //----------------------------------------------------------------------------------
  38. // Ending Screen Functions Definition
  39. //----------------------------------------------------------------------------------
  40. // Ending Screen Initialization logic
  41. void InitEndingScreen(void)
  42. {
  43. // TODO: Initialize ENDING screen variables here!
  44. framesCounter = 0;
  45. finishScreen = 0;
  46. texBackground = LoadTexture("resources/textures/background.png");
  47. texWin = LoadTexture("resources/textures/win.png");
  48. texLose = LoadTexture("resources/textures/lose.png");
  49. texLogo = LoadTexture("resources/textures/logo_raylib.png");
  50. }
  51. // Ending Screen Update logic
  52. void UpdateEndingScreen(void)
  53. {
  54. // TODO: Update ENDING screen variables here!
  55. framesCounter++;
  56. // Press enter to return to TITLE screen
  57. if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
  58. {
  59. finishScreen = 1;
  60. }
  61. }
  62. // Ending Screen Draw logic
  63. void DrawEndingScreen(void)
  64. {
  65. DrawTexture(texBackground, 0, 0, WHITE);
  66. if (endingStatus == 1) // Win
  67. {
  68. DrawTexture(texWin, GetScreenWidth()/2 - texWin.width/2, 90, WHITE);
  69. DrawTextEx(font, "congrats, you got the wave!", (Vector2){ 200, 335 }, font.baseSize, 0, WHITE);
  70. }
  71. else if (endingStatus == 2) // Lose
  72. {
  73. DrawTexture(texLose, GetScreenWidth()/2 - texWin.width/2, 90, WHITE);
  74. DrawTextEx(font, "it seems you lose the wave...", (Vector2){ 205, 335 }, font.baseSize, 0, WHITE);
  75. }
  76. DrawRectangle(0, GetScreenHeight() - 70, 560, 40, Fade(RAYWHITE, 0.8f));
  77. DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 36, GetScreenHeight() - 60, 20, DARKBLUE);
  78. DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY);
  79. DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE);
  80. if ((framesCounter > 80) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to return", (Vector2){ 300, 464 }, font.baseSize, 0, SKYBLUE);
  81. }
  82. // Ending Screen Unload logic
  83. void UnloadEndingScreen(void)
  84. {
  85. // TODO: Unload ENDING screen variables here!
  86. UnloadTexture(texBackground);
  87. UnloadTexture(texWin);
  88. UnloadTexture(texLose);
  89. UnloadTexture(texLogo);
  90. }
  91. // Ending Screen should finish?
  92. int FinishEndingScreen(void)
  93. {
  94. return finishScreen;
  95. }