Skip to content

Commit

Permalink
Move balloon space hit check to balloon where radius can be used for …
Browse files Browse the repository at this point in the history
…better hit test.
  • Loading branch information
rickardlindberg committed May 7, 2023
1 parent 782cda7 commit 7d6c884
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion agdpp.py
Expand Up @@ -321,7 +321,7 @@ def __init__(self, positions, space):
def update(self, dt):
SpriteGroup.update(self, dt)
for balloon in self.get_sprites():
if self.space.hits(balloon.get_position(), 10):
if balloon.hits_space(self.space):
self.remove(balloon)
while len(self.get_sprites()) < 3:
self.spawn_new()
Expand Down Expand Up @@ -518,6 +518,9 @@ def __init__(self, position, radius=40):
self.radius = radius
self.speed = 0.1

def hits_space(self, space):
return space.hits(self.position, self.radius*2)

def inside(self, position):
"""
>>> balloon = Balloon(Point(x=50, y=50), radius=20)
Expand Down

0 comments on commit 7d6c884

Please sign in to comment.