Starter project for SDL2.
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.

27 lines
511 B

  1. #include "IZ_rect.h"
  2. IZ_Bounds IZ_RectGetBounds(IZ_Rect rect) {
  3. return (IZ_Bounds) {
  4. .left = rect.pos.x,
  5. .top = rect.pos.y,
  6. .right = rect.pos.x + rect.width,
  7. .bottom = rect.pos.y + rect.height,
  8. };
  9. }
  10. bool IZ_BoundsContainPoint(IZ_Bounds bounds, IZ_Point2D point) {
  11. return (
  12. bounds.left <= point.x
  13. && bounds.top <= point.y
  14. && point.x <= bounds.right
  15. && point.y <= bounds.bottom
  16. );
  17. }
  18. bool IZ_BoundsCollide(IZ_Bounds a, IZ_Bounds b) {
  19. return (
  20. b.left < a.right
  21. && b.top < a.bottom
  22. );
  23. }