選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

77 行
3.4 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. // Circle shapes and lines
  34. DrawCircle(screenWidth/5, 120, 35, DARKBLUE);
  35. DrawCircleGradient(screenWidth/5, 220, 60, GREEN, SKYBLUE);
  36. DrawCircleLines(screenWidth/5, 340, 80, DARKBLUE);
  37. // Rectangle shapes and ines
  38. DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
  39. DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
  40. DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
  41. // Triangle shapes and lines
  42. DrawTriangle((Vector2){screenWidth/4.0f *3.0f, 80.0f},
  43. (Vector2){screenWidth/4.0f *3.0f - 60.0f, 150.0f},
  44. (Vector2){screenWidth/4.0f *3.0f + 60.0f, 150.0f}, VIOLET);
  45. DrawTriangleLines((Vector2){screenWidth/4.0f*3.0f, 160.0f},
  46. (Vector2){screenWidth/4.0f*3.0f - 20.0f, 230.0f},
  47. (Vector2){screenWidth/4.0f*3.0f + 20.0f, 230.0f}, DARKBLUE);
  48. // Polygon shapes and lines
  49. DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
  50. DrawPolyLinesEx((Vector2){screenWidth/4*3, 320}, 6, 80, 0, 6, BEIGE);
  51. // NOTE: We draw all LINES based shapes together to optimize internal drawing,
  52. // this way, all LINES are rendered in a single draw pass
  53. DrawLine(18, 42, screenWidth - 18, 42, BLACK);
  54. EndDrawing();
  55. //----------------------------------------------------------------------------------
  56. }
  57. // De-Initialization
  58. //--------------------------------------------------------------------------------------
  59. CloseWindow(); // Close window and OpenGL context
  60. //--------------------------------------------------------------------------------------
  61. return 0;
  62. }