CmRect.h 681 B

123456789101112131415161718192021222324252627282930313233
  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(int _x, int _y, int _width, int _height)
  15. :x(_x), y(_y), width(_width), height(_height)
  16. { }
  17. bool contains(Point point)
  18. {
  19. if(point.x >= x && point.x <= (x + width))
  20. {
  21. if(point.y >= y && point.y <= (y + height))
  22. return true;
  23. }
  24. return false;
  25. }
  26. int x, y, width, height;
  27. };
  28. }