Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Simplifying init_level() code.

  • Loading branch information...
commit ed966a15f7a4a922321d029786a85beb40160554 1 parent 17b99c9
Al Sweigart authored August 08, 2012
11  square-shooter/square-shooter_makeover.py
@@ -273,6 +273,7 @@ class GameWorld:
273 273
     high_score = 0
274 274
     lives = 0
275 275
 
  276
+
276 277
     def init_level(self, level):
277 278
         self.level = level
278 279
 
@@ -288,14 +289,12 @@ def init_level(self, level):
288 289
         self.afterdeath_timer = 0
289 290
         self.afterfinish_timer = 0
290 291
 
291  
-        # clear out the bubbles, explosions, and power ups from the last level.
292  
-        del self.bubbles[:]
293  
-        del self.explosions[:]
294  
-        del self.powerups[:]
  292
+        # clear out the explosions, and power ups from the last level.
  293
+        self.explosions = []
  294
+        self.powerups   = []
295 295
 
296 296
         # create a number of starting big bubbles as the level number.
297  
-        for i in range(level):
298  
-            self.bubbles.append(Bubble("big"))
  297
+        self.bubbles = [Bubble("big") for i in range(level)]
299 298
 
300 299
     def update(self, delta_t):
301 300
         self.handle_collisions(delta_t)

0 notes on commit ed966a1

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