Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added comments to GameWorld.update().

  • Loading branch information...
commit da250f068ebce73925a417a3f101d9248635295a 1 parent 3acad00
Al Sweigart authored August 08, 2012

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

  1. 12  square-shooter/square-shooter_makeover.py
12  square-shooter/square-shooter_makeover.py
@@ -298,42 +298,54 @@ def init_level(self, level):
298 298
     def update(self, delta_t):
299 299
         self.handle_collisions(delta_t)
300 300
 
  301
+        # expand the explosions and delete them once they get too big
301 302
         if len(self.explosions) > 0:
302 303
             if self.explosions[0].radius > 0.5:
303 304
                 self.explosions.pop(0)
304 305
         for i in self.explosions:
305 306
             i.radius += delta_t
306 307
 
  308
+        # "age" the powerups on the map, and delete them if they get too old
307 309
         if len(self.powerups) > 0:
308 310
             if self.powerups[0].age > 9:
309 311
                 self.powerups.pop(0)
310 312
         for i in self.powerups:
311 313
             i.age += delta_t
312 314
 
  315
+        # check if all the bubbles have been destroyed
313 316
         if len(self.bubbles) == 0:
314 317
             if self.afterfinish_timer > 0:
  318
+                # the afterfinish timer is still counting down
315 319
                 self.afterfinish_timer -= delta_t;
316 320
             else:
  321
+                # the afterfinish timer is done, add a life and set up the next level
317 322
                 self.level += 1
318 323
                 self.lives += 1
319 324
                 self.init_level(self.level)
320 325
                 return
321 326
         elif not self.ship.has_freeze():
  327
+            # update all the bubbles
322 328
             for i in self.bubbles:
323 329
                 i.update(delta_t)
324 330
 
  331
+        # update the bullet
325 332
         if self.bullet != None:
326 333
             bullet_wrapped = self.bullet.update(delta_t)
327 334
             if bullet_wrapped:
  335
+                # delete the bullet if it has hit the edge of the map
328 336
                 self.bullet = None
329 337
 
  338
+        # update the ship
330 339
         if self.ship == None:
331 340
             if self.afterdeath_timer > 0:
  341
+                # player is dead and afterdeath timer is still counting down
332 342
                 self.afterdeath_timer -= delta_t
333 343
             elif self.lives > 0:
  344
+                # create a new Ship for the next level
334 345
                 self.ship = Ship()
335 346
                 self.ship.add_shield() # add shields at the start of a life
336 347
             else:
  348
+                # player has run out of lives, level 0 will make the start screen display
337 349
                 self.level = 0 # Game over
338 350
             return
339 351
 

0 notes on commit da250f0

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