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.

95 lines
3.2 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Advance Game template
  4. *
  5. * Ending Screen Functions Definitions (Init, Update, Draw, Unload)
  6. *
  7. * Copyright (c) 2014-2019 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 int scrollPositionX;
  34. //----------------------------------------------------------------------------------
  35. // Ending Screen Functions Definition
  36. //----------------------------------------------------------------------------------
  37. // Ending Screen Initialization logic
  38. void InitEndingScreen(void)
  39. {
  40. // TODO: Initialize ENDING screen variables here!
  41. framesCounter = 0;
  42. finishScreen = 0;
  43. PlayMusicStream(music);
  44. }
  45. // Ending Screen Update logic
  46. void UpdateEndingScreen(void)
  47. {
  48. framesCounter++;
  49. scrollPositionX -= 5;
  50. if (scrollPositionX < -GetScreenWidth()) scrollPositionX = 0;
  51. // Press enter or tap to return to TITLE screen
  52. if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
  53. {
  54. finishScreen = 1;
  55. PlaySound(fxCoin);
  56. }
  57. }
  58. // Ending Screen Draw logic
  59. void DrawEndingScreen(void)
  60. {
  61. for (int i = 0; i < 64*2*2; i++)
  62. {
  63. DrawRectangle(64*i + scrollPositionX, 0, 64, GetScreenHeight(), (i%2 == 0)? GetColor(0xf3726dff) : GetColor(0xffcf6bff));
  64. }
  65. if (result == 0) DrawTextEx(font2, "YOU LOOSE...", (Vector2){ 350, 200 }, font2.baseSize*2, 2, WHITE);
  66. else if (result == 1) DrawTextEx(font, "YOU WIN!!!", (Vector2){ 380, 200 }, font.baseSize*2, 2, WHITE);
  67. // Draw score
  68. DrawTextEx(font, FormatText("FINAL SCORE: %i", score), (Vector2){ 400, 360 }, font2.baseSize, 2, WHITE);
  69. if ((framesCounter/30)%2) DrawTextEx(font2, "PRESS ENTER to TITLE", (Vector2){ 340, 550 }, font2.baseSize, 2, WHITE);
  70. }
  71. // Ending Screen Unload logic
  72. void UnloadEndingScreen(void)
  73. {
  74. // TODO: Unload ENDING screen variables here!
  75. }
  76. // Ending Screen should finish?
  77. int FinishEndingScreen(void)
  78. {
  79. return finishScreen;
  80. }