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.

143 lines
4.7 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib - Standard Game template
  4. *
  5. * <Game title>
  6. * <Game description>
  7. *
  8. * This game has been created using raylib (www.raylib.com)
  9. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  10. *
  11. * raylib - Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
  12. *
  13. ********************************************************************************************/
  14. #include "raylib.h"
  15. #include "screens/screens.h" // NOTE: Defines currentScreen
  16. //----------------------------------------------------------------------------------
  17. // Main entry point
  18. //----------------------------------------------------------------------------------
  19. int main(void)
  20. {
  21. // Initialization
  22. //---------------------------------------------------------
  23. const int screenWidth = 800;
  24. const int screenHeight = 450;
  25. const char windowTitle[30] = "<game name goes here>";
  26. InitWindow(screenWidth, screenHeight, windowTitle);
  27. // TODO: Load global data here (assets that must be available in all screens, i.e. fonts)
  28. // Define and init first screen
  29. currentScreen = LOGO; // NOTE: currentScreen is defined in screens.h as a global variable
  30. InitLogoScreen();
  31. SetTargetFPS(60);
  32. //----------------------------------------------------------
  33. // Main game loop
  34. while (!WindowShouldClose()) // Detect window close button or ESC key
  35. {
  36. // Update
  37. //----------------------------------------------------------------------------------
  38. switch(currentScreen)
  39. {
  40. case LOGO:
  41. {
  42. UpdateLogoScreen();
  43. if (FinishLogoScreen())
  44. {
  45. UnloadLogoScreen();
  46. currentScreen = TITLE;
  47. InitTitleScreen();
  48. }
  49. } break;
  50. case TITLE:
  51. {
  52. UpdateTitleScreen();
  53. // NOTE: FinishTitleScreen() return an int defining the screen to jump to
  54. if (FinishTitleScreen() == 1)
  55. {
  56. UnloadTitleScreen();
  57. currentScreen = OPTIONS;
  58. InitOptionsScreen();
  59. }
  60. else if (FinishTitleScreen() == 2)
  61. {
  62. UnloadTitleScreen();
  63. currentScreen = GAMEPLAY;
  64. InitGameplayScreen();
  65. }
  66. } break;
  67. case OPTIONS:
  68. {
  69. UpdateOptionsScreen();
  70. if (FinishOptionsScreen())
  71. {
  72. UnloadOptionsScreen();
  73. currentScreen = TITLE;
  74. InitTitleScreen();
  75. }
  76. } break;
  77. case GAMEPLAY:
  78. {
  79. UpdateGameplayScreen();
  80. if (FinishGameplayScreen())
  81. {
  82. UnloadGameplayScreen();
  83. currentScreen = ENDING;
  84. InitEndingScreen();
  85. }
  86. } break;
  87. case ENDING:
  88. {
  89. UpdateEndingScreen();
  90. if (FinishEndingScreen())
  91. {
  92. UnloadEndingScreen();
  93. currentScreen = TITLE;
  94. InitTitleScreen();
  95. }
  96. } break;
  97. default: break;
  98. }
  99. //----------------------------------------------------------------------------------
  100. // Draw
  101. //----------------------------------------------------------------------------------
  102. BeginDrawing();
  103. ClearBackground(RAYWHITE);
  104. switch(currentScreen)
  105. {
  106. case LOGO: DrawLogoScreen(); break;
  107. case TITLE: DrawTitleScreen(); break;
  108. case OPTIONS: DrawOptionsScreen(); break;
  109. case GAMEPLAY: DrawGameplayScreen(); break;
  110. case ENDING: DrawEndingScreen(); break;
  111. default: break;
  112. }
  113. //DrawFPS(10, 10);
  114. EndDrawing();
  115. //----------------------------------------------------------------------------------
  116. }
  117. // De-Initialization
  118. //--------------------------------------------------------------------------------------
  119. // TODO: Unload all global loaded data (i.e. fonts) here!
  120. CloseWindow(); // Close window and OpenGL context
  121. //--------------------------------------------------------------------------------------
  122. return 0;
  123. }