Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added some comments for the Bubble2D class's methods.

  • Loading branch information...
commit 7cfc5f837a4c936e3a5414c66c87ef0505e54300 1 parent d06453f
Al Sweigart authored August 07, 2012

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  square-shooter/square-shooter_makeover.py
7  square-shooter/square-shooter_makeover.py
@@ -73,17 +73,22 @@ def copy(self, vector):
73 73
         self.x = vector.x
74 74
         self.y = vector.y
75 75
 
  76
+
76 77
 class Bubble2D:
  78
+    """Represents a circular object on the game map with position, radius, and velocity."""
  79
+
77 80
     def __init__(self, radius):
78 81
         self.position = Vector2D(0, 0)
79 82
         self.radius = radius;
80 83
         self.speed = Vector2D(0, 0)
81 84
 
82 85
     def update(self, delta_t):
  86
+        """Update the bubble's position as though delta_t seconds have passed."""
83 87
         self.position.x += self.speed.x * delta_t
84 88
         self.position.y += self.speed.y * delta_t
85 89
 
86 90
     def wrap_around(self):
  91
+        """Change the position of the bubble to toroidally "wrap around" if it goes off one edge of the map."""
87 92
         pos = self.position
88 93
         if pos.x < 0: pos.x = 1
89 94
         if pos.y < 0: pos.y = 1
@@ -91,10 +96,12 @@ def wrap_around(self):
91 96
         if pos.y > 1: pos.y = 0
92 97
 
93 98
     def is_out(self):
  99
+        """Returns True if the center of the bubble is outside the game map, False if it is on the map."""
94 100
         pos = self.position;
95 101
         return pos.x < 0 or pos.y < 0 or pos.x > 1 or pos.y > 1
96 102
 
97 103
     def collides_with(self, bubble):
  104
+        """Returns True if this bubble is intersecting with the Bubble2D object passed in for the bubble parameter."""
98 105
         a = abs(self.position.x - bubble.position.x)
99 106
         b = abs(self.position.y - bubble.position.y)
100 107
         distance = math.sqrt(a * a + b * b)

0 notes on commit 7cfc5f8

Please sign in to comment.
Something went wrong with that request. Please try again.