Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor changes to the collides_with() method.

  • Loading branch information...
commit 4675c45f72e009cc38c6cfb638969187f2cd8729 1 parent ffde511
Al Sweigart authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 square-shooter/square-shooter_makeover.py
10 square-shooter/square-shooter_makeover.py
View
@@ -102,12 +102,12 @@ def is_out(self):
"""Returns True if the center of the bubble is outside the game map, False if it is on the map."""
return not (0 < self.pos.x < 1 and 0 < self.pos.y < 1)
- def collides_with(self, bubble):
- """Returns True if this bubble is intersecting with the Bubble2D object passed in for the bubble parameter."""
- a = abs(self.pos.x - bubble.pos.x)
- b = abs(self.pos.y - bubble.pos.y)
+ def collides_with(self, other):
+ """Returns True if this bubble is intersecting with the Bubble2D object passed in for the "other" parameter."""
+ a = self.pos.x - other.pos.x
+ b = self.pos.y - other.pos.y
distance = math.sqrt(a * a + b * b)
- return distance < (self.radius + bubble.radius)
+ return distance < (self.radius + other.radius)
def random_position():
return (random.random() - 0.5) * 3 + 0.5;
Please sign in to comment.
Something went wrong with that request. Please try again.