Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

97 řádky
4.3 KiB

  1. /*
  2. WELCOME raylib EXAMPLES CONTRIBUTOR!
  3. This is a bsasic template to anyone ready to contribute with some code example for the library,
  4. here there are some guidelines on how to create an example to be included in raylib
  5. 1. File naming: <module>_<description> - Lower case filename, words separated by underscore,
  6. no more than 3-4 words in total to describe the example. <module> referes to the primary
  7. raylib module the example is more related with (code, shapes, textures, models, shaders, raudio).
  8. i.e: core_input_multitouch, shapes_lines_bezier, shaders_palette_switch
  9. 2. Follow below template structure, example info should list the module, the short description
  10. and the author of the example, twitter or github info could be also provided for the author.
  11. Short description should also be used on the title of the window.
  12. 3. Code should be organized by sections:[Initialization]- [Update] - [Draw] - [De-Initialization]
  13. Place your code between the dotted lines for every section, please don't mix update logic with drawing
  14. and remember to unload all loaded resources.
  15. 4. Code should follow raylib conventions: https://github.com/raysan5/raylib/wiki/raylib-coding-conventions
  16. Try to be very organized, using line-breaks appropiately.
  17. 5. Add comments to the specific parts of code the example is focus on.
  18. Don't abuse with comments, try to be clear and impersonal on the comments.
  19. 6. Try to keep the example simple, under 300 code lines if possible. Try to avoid external dependencies.
  20. Try to avoid defining functions outside the main(). Example should be as self-contained as possible.
  21. 7. About external resources, they should be placed in a [resources] folder and those resources
  22. should be open and free for use and distribution. Avoid propietary content.
  23. 8. Try to keep the example simple but with a creative touch.
  24. Simple but beautiful examples are more appealing to users!
  25. 9. In case of additional information is required, just come to raylib Discord channel: example-contributions
  26. 10. Have fun!
  27. */
  28. /*******************************************************************************************
  29. *
  30. * raylib [core] example - Basic window
  31. *
  32. * This example has been created using raylib 2.5 (www.raylib.com)
  33. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  34. *
  35. * Copyright (c) 2019 Ramon Santamaria (@raysan5)
  36. *
  37. ********************************************************************************************/
  38. #include "raylib.h"
  39. int main()
  40. {
  41. // Initialization
  42. //--------------------------------------------------------------------------------------
  43. const int screenWidth = 800;
  44. const int screenHeight = 450;
  45. InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
  46. // TODO: Load resources / Initialize variables at this point
  47. SetTargetFPS(60);
  48. //--------------------------------------------------------------------------------------
  49. // Main game loop
  50. while (!WindowShouldClose()) // Detect window close button or ESC key
  51. {
  52. // Update
  53. //----------------------------------------------------------------------------------
  54. // TODO: Update variables / Implement example logic at this point
  55. //----------------------------------------------------------------------------------
  56. // Draw
  57. //----------------------------------------------------------------------------------
  58. BeginDrawing();
  59. ClearBackground(RAYWHITE);
  60. // TODO: Draw everything that requires to be drawn at this point:
  61. DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); // Example
  62. EndDrawing();
  63. //----------------------------------------------------------------------------------
  64. }
  65. // De-Initialization
  66. //--------------------------------------------------------------------------------------
  67. // TODO: Unload all loaded resources at this point
  68. CloseWindow(); // Close window and OpenGL context
  69. //--------------------------------------------------------------------------------------
  70. return 0;
  71. }