Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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