Browse Source

Add 'Contains' function for 'Rectangle'

This will be useful for various bound checks throughout the code.
pull/2252/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
d93e1fdf07
  1. 8
      Source/engine/rectangle.hpp

8
Source/engine/rectangle.hpp

@ -8,6 +8,14 @@ namespace devilution {
struct Rectangle {
Point position;
Size size;
constexpr bool Contains(Point point) const
{
return point.x >= this->position.x
&& point.x <= (this->position.x + this->size.width)
&& point.y >= this->position.y
&& point.y <= (this->position.y + this->size.height);
}
};
} // namespace devilution

Loading…
Cancel
Save