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.

194 lines
5.7 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Simple Game template
  4. *
  5. * Screens Functions Definitions (Init, Update, Draw, Unload)
  6. *
  7. * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
  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 (visible to other modules)
  29. //----------------------------------------------------------------------------------
  30. GameScreen currentScreen = LOGO;
  31. //----------------------------------------------------------------------------------
  32. // Global Variables Definition (local to this module)
  33. //----------------------------------------------------------------------------------
  34. // Logo screen global variables
  35. static int framesCounter;
  36. // Title screen global variables
  37. // Gameplay screen global variables
  38. // Ending screen global variables
  39. //----------------------------------------------------------------------------------
  40. // Logo Screen Functions Definition
  41. //----------------------------------------------------------------------------------
  42. // Logo Screen Initialization logic
  43. void InitLogoScreen(void)
  44. {
  45. // TODO: Initialize LOGO screen variables here!
  46. framesCounter = 0;
  47. }
  48. // Logo Screen Update logic
  49. void UpdateLogoScreen(void)
  50. {
  51. // TODO: Update LOGO screen variables here!
  52. framesCounter++; // Count frames
  53. // Wait for 2 seconds (120 frames) before jumping to TITLE screen
  54. if (framesCounter > 120)
  55. {
  56. currentScreen = TITLE;
  57. }
  58. }
  59. // Logo Screen Draw logic
  60. void DrawLogoScreen(void)
  61. {
  62. // TODO: Draw LOGO screen here!
  63. DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
  64. DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY);
  65. }
  66. // Logo Screen Unload logic
  67. void UnloadLogoScreen(void)
  68. {
  69. // TODO: Unload LOGO screen variables here!
  70. }
  71. //----------------------------------------------------------------------------------
  72. // Title Screen Functions Definition
  73. //----------------------------------------------------------------------------------
  74. // Title Screen Initialization logic
  75. void InitTitleScreen(void)
  76. {
  77. // TODO: Initialize TITLE screen variables here!
  78. }
  79. // Title Screen Update logic
  80. void UpdateTitleScreen(void)
  81. {
  82. // TODO: Update TITLE screen variables here!
  83. // Press enter to change to GAMEPLAY screen
  84. if (IsKeyPressed(KEY_ENTER))
  85. {
  86. currentScreen = GAMEPLAY;
  87. }
  88. }
  89. // Title Screen Draw logic
  90. void DrawTitleScreen(void)
  91. {
  92. // TODO: Draw TITLE screen here!
  93. DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
  94. DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
  95. DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
  96. }
  97. // Title Screen Unload logic
  98. void UnloadTitleScreen(void)
  99. {
  100. // TODO: Unload TITLE screen variables here!
  101. }
  102. //----------------------------------------------------------------------------------
  103. // Gameplay Screen Functions Definition
  104. //----------------------------------------------------------------------------------
  105. // Gameplay Screen Initialization logic
  106. void InitGameplayScreen(void)
  107. {
  108. // TODO: Initialize GAMEPLAY screen variables here!
  109. }
  110. // Gameplay Screen Update logic
  111. void UpdateGameplayScreen(void)
  112. {
  113. // TODO: Update GAMEPLAY screen variables here!
  114. // Press enter to change to ENDING screen
  115. if (IsKeyPressed(KEY_ENTER))
  116. {
  117. currentScreen = ENDING;
  118. }
  119. }
  120. // Gameplay Screen Draw logic
  121. void DrawGameplayScreen(void)
  122. {
  123. // TODO: Draw GAMEPLAY screen here!
  124. DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE);
  125. DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
  126. DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
  127. }
  128. // Gameplay Screen Unload logic
  129. void UnloadGameplayScreen(void)
  130. {
  131. // TODO: Unload GAMEPLAY screen variables here!
  132. }
  133. //----------------------------------------------------------------------------------
  134. // Ending Screen Functions Definition
  135. //----------------------------------------------------------------------------------
  136. // Ending Screen Initialization logic
  137. void InitEndingScreen(void)
  138. {
  139. // TODO: Initialize ENDING screen variables here!
  140. }
  141. // Ending Screen Update logic
  142. void UpdateEndingScreen(void)
  143. {
  144. // TODO: Update ENDING screen variables here!
  145. // Press enter to return to TITLE screen
  146. if (IsKeyPressed(KEY_ENTER))
  147. {
  148. currentScreen = TITLE;
  149. }
  150. }
  151. // Ending Screen Draw logic
  152. void DrawEndingScreen(void)
  153. {
  154. // TODO: Draw ENDING screen here!
  155. DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
  156. DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
  157. DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
  158. }
  159. // Ending Screen Unload logic
  160. void UnloadEndingScreen(void)
  161. {
  162. // TODO: Unload ENDING screen variables here!
  163. }