diff options
Diffstat (limited to 'tree.py')
-rw-r--r-- | tree.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -3,11 +3,16 @@ from random import randint tree_images_number = 3 tree_images = ["images/tree_%02d.png" % tree_images_number for tree_images_number in xrange(1, tree_images_number + 1) ] +cutting_time = 100 class Tree: def __init__(self, position): + self.cutting_time = cutting_time + self.sprout_time = 0 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") + self.sprout_image = pygame.image.load("images/sprout.png") image_rect = self.image.get_rect() size_reduction = 10 self.collision_rect = pygame.Rect(image_rect.left - size_reduction, \ @@ -16,7 +21,21 @@ class Tree: image_rect.height - size_reduction) def draw(self, on_surface): - on_surface.blit(self.image, self.position) + if self.sprout_time == 200: + on_surface.blit(self.image, self.position) + else: + sprout_text = str(self.sprout_time) + font = pygame.font.Font(None, 24) + text = font.render( sprout_text , 1, (0, 0, 0, 0)) + on_surface.blit(self.sprout_image, self.position) + on_surface.blit( text, self.position) + + def draw_alert(self, on_surface): + on_surface.blit(self.alert_image, self.position) + cutting_text = str(self.cutting_time) + font = pygame.font.Font(None, 24) + text = font.render( cutting_text , 1, (0, 0, 0, 0)) + on_surface.blit( text, self.position) def collides_with(self, other): return self.get_absolute_rect().colliderect(other.get_absolute_rect()) |