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.

125 line
4.0 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib game - Dr. Turtle & Mr. Gamera
  4. *
  5. * Welcome to raylib!
  6. *
  7. * To test examples, just press F6 and execute raylib_compile_execute script
  8. * Note that compiled executable is placed in the same folder as .c file
  9. *
  10. * You can find all basic examples on C:\raylib\raylib\examples folder or
  11. * raylib official webpage: www.raylib.com
  12. *
  13. * Enjoy using raylib. :)
  14. *
  15. * This game has been created using raylib 1.1 (www.raylib.com)
  16. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  17. *
  18. * Copyright (c) 2014 Ramon Santamaria (@raysan5)
  19. *
  20. ********************************************************************************************/
  21. #include "raylib.h"
  22. #define MAX_ENEMIES 10
  23. typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen;
  24. int main()
  25. {
  26. // Initialization
  27. //--------------------------------------------------------------------------------------
  28. const int screenWidth = 1280;
  29. const int screenHeight = 720;
  30. // Init window
  31. InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA");
  32. // Define current screen
  33. GameScreen currentScreen = TITLE;
  34. SetTargetFPS(60); // Setup game frames per second
  35. //--------------------------------------------------------------------------------------
  36. // Main game loop
  37. while (!WindowShouldClose()) // Detect window close button or ESC key
  38. {
  39. // Update
  40. //----------------------------------------------------------------------------------
  41. // Game screens management
  42. switch (currentScreen)
  43. {
  44. case TITLE:
  45. {
  46. // Press enter to change to gameplay screen
  47. if (IsKeyPressed(KEY_ENTER))
  48. {
  49. currentScreen = GAMEPLAY;
  50. }
  51. } break;
  52. case GAMEPLAY:
  53. {
  54. // Press enter to change to ending screen
  55. if (IsKeyPressed(KEY_ENTER))
  56. {
  57. currentScreen = ENDING;
  58. }
  59. } break;
  60. case ENDING:
  61. {
  62. // Press enter to change to title screen
  63. if (IsKeyPressed(KEY_ENTER))
  64. {
  65. currentScreen = TITLE;
  66. }
  67. } break;
  68. default: break;
  69. }
  70. //----------------------------------------------------------------------------------
  71. // Draw
  72. //----------------------------------------------------------------------------------
  73. BeginDrawing();
  74. ClearBackground(RAYWHITE);
  75. switch (currentScreen)
  76. {
  77. case TITLE:
  78. {
  79. // Draw title screen
  80. DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
  81. DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
  82. } break;
  83. case GAMEPLAY:
  84. {
  85. // Draw gameplay screen
  86. DrawRectangle(0, 0, screenWidth, screenHeight, RED);
  87. DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
  88. } break;
  89. case ENDING:
  90. {
  91. // Draw ending screen
  92. DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
  93. DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
  94. } break;
  95. default: break;
  96. }
  97. EndDrawing();
  98. //----------------------------------------------------------------------------------
  99. }
  100. // De-Initialization
  101. //--------------------------------------------------------------------------------------
  102. CloseWindow(); // Close window and OpenGL context
  103. //--------------------------------------------------------------------------------------
  104. return 0;
  105. }