Skip to content

Commit

Permalink
Fix #1999 (#2003)
Browse files Browse the repository at this point in the history
  • Loading branch information
eruvanos committed Feb 28, 2024
1 parent 48146fb commit 6255f79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion arcade/gui/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def move(self, dx: float = 0, dy: float = 0):

def collide_with_point(self, x, y):
left, bottom, width, height = self
return left < x < left + width and bottom < y < bottom + height
return left <= x <= left + width and bottom <= y <= bottom + height

def scale(self, scale: float) -> "Rect":
"""Returns a new rect with scale applied"""
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/gui/test_rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,12 @@ def test_rect_union():

# THEN
assert new_rect == (0, 0, 20, 10)


def test_collide_with_point():
rect = Rect(0, 0, 100, 100)

assert rect.collide_with_point(0, 0)
assert rect.collide_with_point(50, 50)
assert rect.collide_with_point(100, 100)
assert not rect.collide_with_point(150, 150)

0 comments on commit 6255f79

Please sign in to comment.