Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

151 Zeilen
5.4 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib - Basic Game template
  4. *
  5. * <Game title>
  6. * <Game description>
  7. *
  8. * This game has been created using raylib v1.2 (www.raylib.com)
  9. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  10. *
  11. * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
  12. *
  13. ********************************************************************************************/
  14. #include "raylib.h"
  15. //----------------------------------------------------------------------------------
  16. // Types and Structures Definition
  17. //----------------------------------------------------------------------------------
  18. typedef enum GameScreen { LOGO, TITLE, GAMEPLAY, ENDING } GameScreen;
  19. //----------------------------------------------------------------------------------
  20. // Main entry point
  21. //----------------------------------------------------------------------------------
  22. int main()
  23. {
  24. // Initialization
  25. //--------------------------------------------------------------------------------------
  26. const int screenWidth = 800;
  27. const int screenHeight = 450;
  28. const char windowTitle[30] = "<game name goes here>";
  29. GameScreen currentScreen = LOGO;
  30. InitWindow(screenWidth, screenHeight, windowTitle);
  31. // TODO: Initialize all required variables and load all required data here!
  32. int framesCounter = 0; // Used to count frames
  33. SetTargetFPS(60);
  34. //--------------------------------------------------------------------------------------
  35. // Main game loop
  36. while (!WindowShouldClose()) // Detect window close button or ESC key
  37. {
  38. // Update
  39. //----------------------------------------------------------------------------------
  40. switch(currentScreen)
  41. {
  42. case LOGO:
  43. {
  44. // TODO: Update LOGO screen variables here!
  45. framesCounter++; // Count frames
  46. // Wait for 2 seconds (120 frames) before jumping to TITLE screen
  47. if (framesCounter > 120)
  48. {
  49. currentScreen = TITLE;
  50. }
  51. } break;
  52. case TITLE:
  53. {
  54. // TODO: Update TITLE screen variables here!
  55. // Press enter to change to GAMEPLAY screen
  56. if (IsKeyPressed(KEY_ENTER))
  57. {
  58. currentScreen = GAMEPLAY;
  59. }
  60. } break;
  61. case GAMEPLAY:
  62. {
  63. // TODO: Update GAMEPLAY screen variables here!
  64. // Press enter to change to ENDING screen
  65. if (IsKeyPressed(KEY_ENTER))
  66. {
  67. currentScreen = ENDING;
  68. }
  69. } break;
  70. case ENDING:
  71. {
  72. // TODO: Update ENDING screen variables here!
  73. // Press enter to return to TITLE screen
  74. if (IsKeyPressed(KEY_ENTER))
  75. {
  76. currentScreen = TITLE;
  77. }
  78. } break;
  79. default: break;
  80. }
  81. //----------------------------------------------------------------------------------
  82. // Draw
  83. //----------------------------------------------------------------------------------
  84. BeginDrawing();
  85. ClearBackground(RAYWHITE);
  86. switch(currentScreen)
  87. {
  88. case LOGO:
  89. {
  90. // TODO: Draw LOGO screen here!
  91. DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
  92. DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY);
  93. } break;
  94. case TITLE:
  95. {
  96. // TODO: Draw TITLE screen here!
  97. DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
  98. DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
  99. DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
  100. } break;
  101. case GAMEPLAY:
  102. {
  103. // TODO: Draw GAMEPLAY screen here!
  104. DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE);
  105. DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
  106. DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
  107. } break;
  108. case ENDING:
  109. {
  110. // TODO: Draw ENDING screen here!
  111. DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
  112. DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
  113. DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
  114. } break;
  115. default: break;
  116. }
  117. EndDrawing();
  118. //----------------------------------------------------------------------------------
  119. }
  120. // De-Initialization
  121. //--------------------------------------------------------------------------------------
  122. // TODO: Unload all loaded data (textures, fonts, audio) here!
  123. CloseWindow(); // Close window and OpenGL context
  124. //--------------------------------------------------------------------------------------
  125. return 0;
  126. }