Skip to content

Commit

Permalink
Apply same early return style in size.setter
Browse files Browse the repository at this point in the history
  • Loading branch information
pushfoo committed Jul 19, 2024
1 parent a959a02 commit 1a5886c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions arcade/sprite/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,18 @@ def size(self, new_value: Point2):
"size must be a tuple-like object which unpacks to exactly 2 coordinates"
)
old_size = self._size
if old_size[0] != width or old_size[1] != height:
texture_size = self._texture.size
new_size = Vec2(width, height)
self._scale = new_size / texture_size
self._size = new_size
if old_size[0] == width and old_size[1] == height:
return

self.update_spatial_hash()
texture_size = self._texture.size
new_size = Vec2(width, height)
self._scale = new_size / texture_size
self._size = new_size

for sprite_list in self.sprite_lists:
sprite_list._update_size(self)
self.update_spatial_hash()

for sprite_list in self.sprite_lists:
sprite_list._update_size(self)

@property
def scale_x(self) -> float:
Expand Down

0 comments on commit 1a5886c

Please sign in to comment.