diff options
author | Rodolfo D. Arce S <rodolfo.arce.s@gmail.com> | 2011-06-02 22:54:53 (GMT) |
---|---|---|
committer | Rodolfo D. Arce S <rodolfo.arce.s@gmail.com> | 2011-06-02 22:54:53 (GMT) |
commit | 4423bd10c3b2a83c998cc3e2f72cc7df1565a0be (patch) | |
tree | 02d555994261278651bc23b0467a2652790a3f84 | |
parent | 673030360fe25001dd1fe34c7d57041df98b3bb7 (diff) |
Tree cutters kill trees, ranger kills tree cutters.
-rw-r--r-- | main.py | 41 |
1 files changed, 26 insertions, 15 deletions
@@ -39,7 +39,7 @@ ranger = Ranger(window_h, window_w, ranger_speed) # Cutter cutter_time = 100 -cutter_speed = 3 +cutter_speed = 4 cutter = [] @@ -93,30 +93,41 @@ while True: # Draw background screen.fill(bg_color) - # Score text - for arbol in trees: - score += 1 - - score_text = "Air: " + str(score) + " Planting in : " + str(plant_time) - font = pygame.font.Font(None, 36) - text = font.render( score_text , 1, (0, 0, 0, 0)) - screen.blit(text, (0, 0)) - # Score updates - score = 0 - ranger.draw(screen) for treecutter in cutter: treecutter.draw(screen) - if cutter_time == 150: + # Ranger kills tree cutters + for cortador in cutter: + if ranger.collides_with(cortador): + cutter.remove(cortador) + + # Tree cutters kills trees + for arbol in trees: + for cortador in cutter: + if cortador.collides_with(arbol): + trees.remove(arbol) + + if cutter_time == 100: cutter.append( Cutter(window_h, window_w, cutter_speed) ) cutter_time = 0 cutter_time += 1 - - + for arbol in trees: arbol.draw(screen) + + ## SCORE IS DRAWN AFTER EVERYTHING ELSE + # Score is equal to amount of trees + for arbol in trees: + score += 1 + # Score text + score_text = "Air: " + str(score) + " Planting in : " + str(plant_time) + font = pygame.font.Font(None, 36) + text = font.render( score_text , 1, (0, 0, 0, 0)) + screen.blit(text, (0, 0)) + # Score updates after being shown + score = 0 pygame.display.update() |