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.

97 lines
3.5 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib - Simple 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.h"
  16. //----------------------------------------------------------------------------------
  17. // Global Variables Defined in other modules
  18. //----------------------------------------------------------------------------------
  19. extern GameScreen currentScreen; // Defined in screens.c
  20. //----------------------------------------------------------------------------------
  21. // Main entry point
  22. //----------------------------------------------------------------------------------
  23. int main(void)
  24. {
  25. // Initialization
  26. //---------------------------------------------------------
  27. const int screenWidth = 800;
  28. const int screenHeight = 450;
  29. const char windowTitle[30] = "<game name goes here>";
  30. InitWindow(screenWidth, screenHeight, windowTitle);
  31. // Initialize all screens
  32. InitLogoScreen();
  33. InitTitleScreen();
  34. InitGameplayScreen();
  35. InitEndingScreen();
  36. // Define first screen
  37. currentScreen = LOGO;
  38. SetTargetFPS(60);
  39. //----------------------------------------------------------
  40. // Main game loop
  41. while (!WindowShouldClose()) // Detect window close button or ESC key
  42. {
  43. // Update
  44. //----------------------------------------------------------------------------------
  45. switch(currentScreen)
  46. {
  47. case LOGO: UpdateLogoScreen(); break; // Update LOGO currentScreen
  48. case TITLE: UpdateTitleScreen(); break; // Update TITLE currentScreen
  49. case GAMEPLAY: UpdateGameplayScreen(); break; // Update GAMEPLAY currentScreen
  50. case ENDING: UpdateEndingScreen(); break; // Update END currentScreen
  51. default: break;
  52. }
  53. //----------------------------------------------------------------------------------
  54. // Draw
  55. //----------------------------------------------------------------------------------
  56. BeginDrawing();
  57. ClearBackground(RAYWHITE);
  58. switch(currentScreen)
  59. {
  60. case LOGO: DrawLogoScreen(); break; // Draw LOGO currentScreen
  61. case TITLE: DrawTitleScreen(); break; // Draw TITLE currentScreen
  62. case GAMEPLAY: DrawGameplayScreen(); break; // Draw GAMEPLAY currentScreen
  63. case ENDING: DrawEndingScreen(); break; // Draw END currentScreen
  64. default: break;
  65. }
  66. DrawFPS(screenWidth - 100, 20);
  67. EndDrawing();
  68. //----------------------------------------------------------------------------------
  69. }
  70. // De-Initialization
  71. //--------------------------------------------------------------------------------------
  72. // Unload all loaded data (textures, fonts, audio)
  73. UnloadLogoScreen();
  74. UnloadTitleScreen();
  75. UnloadGameplayScreen();
  76. UnloadEndingScreen();
  77. CloseWindow(); // Close window and OpenGL context
  78. //--------------------------------------------------------------------------------------
  79. return 0;
  80. }