CmRect.h 737 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. #include "CmPoint.h"
  4. namespace CamelotEngine
  5. {
  6. /**
  7. * @brief A rectangle. Although you may use any coordinate system, Camelot assumes
  8. * that X, Y values represent its bottom left corner, where X increases to the right,
  9. * and Y increases upwards.
  10. */
  11. class Rect
  12. {
  13. public:
  14. Rect()
  15. :x(0), y(0), width(0), height(0)
  16. { }
  17. Rect(int _x, int _y, int _width, int _height)
  18. :x(_x), y(_y), width(_width), height(_height)
  19. { }
  20. bool contains(Point point)
  21. {
  22. if(point.x >= x && point.x <= (x + width))
  23. {
  24. if(point.y >= y && point.y <= (y + height))
  25. return true;
  26. }
  27. return false;
  28. }
  29. int x, y, width, height;
  30. };
  31. }