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.

72 lines
3.1 KiB

пре 5 година
пре 5 година
пре 5 година
пре 11 година
пре 7 година
пре 11 година
пре 11 година
пре 11 година
  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*3, 80},
  38. (Vector2){screenWidth/4*3 - 60, 150},
  39. (Vector2){screenWidth/4*3 + 60, 150}, 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*3, 160},
  47. (Vector2){screenWidth/4*3 - 20, 230},
  48. (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
  49. EndDrawing();
  50. //----------------------------------------------------------------------------------
  51. }
  52. // De-Initialization
  53. //--------------------------------------------------------------------------------------
  54. CloseWindow(); // Close window and OpenGL context
  55. //--------------------------------------------------------------------------------------
  56. return 0;
  57. }