25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

72 satır
3.2 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
  4. *
  5. * This example has been created using raylib 1.0 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2014 Ramon Santamaria (@raysan5)
  9. *
  10. ********************************************************************************************/
  11. #include "raylib.h"
  12. int main(void)
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. const int screenWidth = 800;
  17. const int screenHeight = 450;
  18. InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
  19. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  20. //--------------------------------------------------------------------------------------
  21. // Main game loop
  22. while (!WindowShouldClose()) // Detect window close button or ESC key
  23. {
  24. // Update
  25. //----------------------------------------------------------------------------------
  26. // TODO: Update your variables here
  27. //----------------------------------------------------------------------------------
  28. // Draw
  29. //----------------------------------------------------------------------------------
  30. BeginDrawing();
  31. ClearBackground(RAYWHITE);
  32. DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
  33. DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
  34. DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
  35. DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
  36. DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
  37. DrawTriangle((Vector2){screenWidth/4.0f *3.0f, 80.0f},
  38. (Vector2){screenWidth/4.0f *3.0f - 60.0f, 150.0f},
  39. (Vector2){screenWidth/4.0f *3.0f + 60.0f, 150.0f}, VIOLET);
  40. DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
  41. DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
  42. // NOTE: We draw all LINES based shapes together to optimize internal drawing,
  43. // this way, all LINES are rendered in a single draw pass
  44. DrawLine(18, 42, screenWidth - 18, 42, BLACK);
  45. DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
  46. DrawTriangleLines((Vector2){screenWidth/4.0f*3.0f, 160.0f},
  47. (Vector2){screenWidth/4.0f*3.0f - 20.0f, 230.0f},
  48. (Vector2){screenWidth/4.0f*3.0f + 20.0f, 230.0f}, DARKBLUE);
  49. EndDrawing();
  50. //----------------------------------------------------------------------------------
  51. }
  52. // De-Initialization
  53. //--------------------------------------------------------------------------------------
  54. CloseWindow(); // Close window and OpenGL context
  55. //--------------------------------------------------------------------------------------
  56. return 0;
  57. }