Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added some more comments to Bubble and Powerup classes.

  • Loading branch information...
commit a6f8972473d7ced51bf709a766852163f5c7142c 1 parent f30ae54
Al Sweigart authored
12  square-shooter/square-shooter_makeover.py
@@ -137,20 +137,22 @@ def __init__(self, kind):
137 137
         self.color = random.choice(Bubble.colors)
138 138
 
139 139
     def spawn(self):
140  
-        spawned_bubbles = []
141  
-        spawned_powerups = []
  140
+        """Returns a list of created Bubble and Powerup objects that result when this Bubble is hit. These new objects' positions are the same as this Bubble's position."""
  141
+        spawned_bubbles = []  # the newly created Bubble object(s)
  142
+        spawned_powerups = [] # the newly created Powerup object(s)
142 143
 
143 144
         if self.kind == "small":
  145
+            # Small Bubbles do not create new Bubbles, but might create Powerups.
144 146
             if random.random() < 0.25:
145 147
                 spawned_powerups.append(Powerup(self.pos))
146 148
         else:
147  
-            print(self.kind)
  149
+            # Medium and Big Bubbles create new Bubble objects of the next smaller size. They don't create Powerups.
148 150
             if self.kind == "medium":
149 151
                 new_kind = "small"
150 152
             elif self.kind == "big":
151 153
                 new_kind = "medium"
152 154
 
153  
-            for i in range(2):
  155
+            for i in range(2): # creates two new Bubbles
154 156
                 spawned_bubbles.append(Bubble(new_kind))
155 157
                 spawned_bubbles[-1].pos.copy(self.pos)
156 158
 
@@ -159,7 +161,7 @@ def spawn(self):
159 161
 
160 162
 class Powerup(ObjectOnMap):
161 163
     def __init__(self, pos):
162  
-        super(Powerup, self).__init__(0.03)
  164
+        super(Powerup, self).__init__(0.03) # all Powerups are the same size.
163 165
         self.pos.copy(pos)
164 166
         self.kind = random.choice(("shield", "bullet", "freeze"))
165 167
         self.age = 0

0 notes on commit a6f8972

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