From b596b67f6f81eb61303106811af1c335c9abdaec Mon Sep 17 00:00:00 2001 From: Rodolfo D. Arce S Date: Fri, 10 Jun 2011 14:54:45 +0000 Subject: Tree cutters appearence time based on score. The game is ready for realese --- diff --git a/README b/README index 8189535..8931fc0 100644 --- a/README +++ b/README @@ -1,4 +1,10 @@ -Rodolfo D. Arce S. +"Rodolfo D. Arce S." This is a game about a forest ranger that stops tree cutters +Instructions: + +Tree cutters appear at a certain period of time, the more you tree cutters you get the faster they'll appear next time. + +Press "p" to plant trees so you don't loose the game. If you end up with no trees you loose the game. + diff --git a/cutter.py b/cutter.py index 77f248f..f228863 100644 --- a/cutter.py +++ b/cutter.py @@ -12,9 +12,9 @@ class Cutter: self.cut_time = cut_time_left self.image = pygame.image.load(cutter_images[randint(0, cutter_images_number - 1)]) image_rect = self.image.get_rect() - size_reduction = 10 - self.collision_rect = pygame.Rect(image_rect.left - size_reduction, \ - image_rect.top - size_reduction, \ + size_reduction = 5 + self.collision_rect = pygame.Rect(image_rect.left + size_reduction, \ + image_rect.top + size_reduction, \ image_rect.width - size_reduction, \ image_rect.height - size_reduction) self.screen_w = screen_w diff --git a/main.py b/main.py index 8edc158..3600a6e 100644 --- a/main.py +++ b/main.py @@ -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() diff --git a/ranger.py b/ranger.py index 6769c57..5d09147 100644 --- a/ranger.py +++ b/ranger.py @@ -8,11 +8,11 @@ class Ranger: self.speed = ranger_speed self.image = pygame.image.load("images/ranger_hat.png") image_rect = self.image.get_rect() - size_reduction = 5 + size_reduction = 10 self.collision_rect = pygame.Rect(image_rect.left + size_reduction, \ image_rect.top + size_reduction, \ - image_rect.width - size_reduction, \ - image_rect.height - size_reduction) + image_rect.width - size_reduction/2, \ + image_rect.height - size_reduction/2 ) self.position = [0, 0] self.screen_w = screen_w self.screen_h = screen_h diff --git a/tree.py b/tree.py index 5e98151..ef51e29 100644 --- a/tree.py +++ b/tree.py @@ -8,7 +8,7 @@ cutting_time = 100 class Tree: def __init__(self, position): self.cutting_time = cutting_time - self.sprout_time = 0 + self.sprout_time = 200 self.position = position self.image = pygame.image.load(tree_images[randint(0, tree_images_number - 1)]) self.alert_image = pygame.image.load("images/atention.png") @@ -21,7 +21,7 @@ class Tree: image_rect.height - size_reduction) def draw(self, on_surface): - if self.sprout_time == 200: + if self.sprout_time <= 0: on_surface.blit(self.image, self.position) else: sprout_text = str(self.sprout_time) -- cgit v0.9.1