2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
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.

IZ_rect.c 520 B

1234567891011121314151617181920212223242526
  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_RectBoundsContainPoint(IZ_Bounds bounds, IZ_Vector2D 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_RectBoundsCollide(IZ_Bounds a, IZ_Bounds b) {
  19. return (
  20. b.left < a.right
  21. && b.top < a.bottom
  22. );
  23. }