diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 56 |
1 files changed, 39 insertions, 17 deletions
@@ -27,7 +27,6 @@ window_h, window_w = screen.get_size () # Tree -plant_time = 10 trees = [] start_time = time.time() @@ -35,8 +34,13 @@ fps = 60 frame_time = 1.0/fps # Ranger +# Button sensibility when planting +button_time = 30 +plant_time = 30 +# Speed and movement unit = 1 -ranger_speed = 4 +ranger_speed = 10 +# The ranger object ranger = Ranger(window_h, window_w, ranger_speed) # Cutter @@ -45,7 +49,8 @@ tree_cutting_time = 50 cutter_speed = 4 cutter = [] - +# Difficulty level +cutter_difficulty = 300 # Draw background screen.fill(bg_color) @@ -56,9 +61,10 @@ while number_trees != 0: number_trees -= 1 for arbol in trees: - arbol.sprout_time = 200 + arbol.sprout_time = 0 +air = 0 score = 0 while True: @@ -87,8 +93,7 @@ while True: if ranger.new_plant == True: plant_time += 1 - #trees.append(Tree( new_plant_position ) ) - if plant_time > 50: + if plant_time > button_time: trees.append(Tree( new_plant_position ) ) plant_time = 0 ranger.new_plant = False @@ -107,15 +112,17 @@ while True: for treecutter in cutter: treecutter.draw(screen) - # Ranger kills tree cutters + # Ranger kills tree cutters and adds points for cortador in cutter: if ranger.collides_with(cortador): cutter.remove(cortador) + score += 1 + # Draw trees or grow them for arbol in trees: - if arbol.sprout_time < 200: - arbol.sprout_time += 1 + if arbol.sprout_time > 0: + arbol.sprout_time -= 1 arbol.draw(screen) # Tree cutters kills trees @@ -126,12 +133,12 @@ while True: arbol.draw_alert(screen) cortador.cut_time += 1 arbol.cutting_time -=1 - if cortador.cut_tree == True and cortador.cut_time == 100: + if cortador.cut_tree == True and cortador.cut_time == 100 or arbol.cutting_time == 0: trees.remove(arbol) cortador.cut_time = 0 cortador.cut_tree = False - if cutter_time == 300: + if cutter_time >= cutter_difficulty: cutter.append( Cutter(window_h, window_w, cutter_speed, 0) ) cutter_time = 0 cutter_time += 1 @@ -141,13 +148,28 @@ while True: ## 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) + air += 1 + + # HUD text + hud_text = "Air: " + str(air) + " Score: " + str(score) font = pygame.font.Font(None, 36) - text = font.render( score_text , 1, (0, 0, 0, 0)) - screen.blit(text, (0, 0)) + text_hud = font.render( hud_text , 1, (0, 0, 0, 0)) + screen.blit(text_hud, (0, 0)) + + # Difilcuty level based on score + if score >= 0: + if score <= 10: + cutter_difficulty = 200 + elif score <= 20: + cutter_difficulty = 100 + elif score <= 50: + cutter_difficulty = 175 + elif score <= 100: + cutter_difficulty = 100 + elif score <= 150: + cutter_difficulty = 50 + # Score updates after being shown - score = 0 + air = 0 pygame.display.update() |