diff --git a/code/rect.lua b/code/rect.lua index 55e84a8..32787e7 100644 --- a/code/rect.lua +++ b/code/rect.lua @@ -15,7 +15,7 @@ end -- clone refers to a deep copy function Rect:clone() - return Rect:fromCoods(self.min.x, self.min.y, self.max.x, self.max.y) + return Rect:fromCoords(self.min.x, self.min.y, self.max.x, self.max.y) end -- make sure min and max refer to the correct corners @@ -55,15 +55,17 @@ function Rect:corners() end function Rect:containsPoint(pt) - return self.min.x < pt.x and - self.min.y < pt.y and - pt.x < self.max.x and - pt.y < self.max.y + return pt.x >= self.min.x + and pt.y >= self.min.y + and pt.x <= self.max.x + and pt.y <= self.max.y end function Rect:overlapsRect(other) - return self.min.x other.min.x + and self.min.y < other.max.y + and self.max.y > other.min.y end function Rect:draw(style)