A 2D tile-based sandbox game.
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ů.

BodyTrait.h 921B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include "../common.h"
  3. namespace Swan {
  4. class Win;
  5. struct BodyTrait {
  6. struct Body;
  7. struct Tag {};
  8. virtual Body &get(Tag) = 0;
  9. struct Body {
  10. Vec2 pos{};
  11. Vec2 size{};
  12. float left() { return pos.x; }
  13. float right() { return pos.x + size.x; }
  14. float midX() { return pos.x + size.x / 2; }
  15. float top() { return pos.y; }
  16. float bottom() { return pos.y + size.y; }
  17. float midY() { return pos.y + size.y / 2; }
  18. Vec2 topLeft() { return { left(), top() }; }
  19. Vec2 midLeft() { return { left(), midY() }; }
  20. Vec2 bottomLeft() { return { left(), bottom() }; }
  21. Vec2 topMid() { return { midX(), top() }; }
  22. Vec2 center() { return { midX(), midY() }; }
  23. Vec2 bottomMid() { return { midX(), bottom() }; }
  24. Vec2 topRight() { return { right(), top() }; }
  25. Vec2 midRight() { return { right(), midY() }; }
  26. Vec2 bottomRight() { return { right(), bottom() }; }
  27. void outline(Win &win);
  28. };
  29. };
  30. }