diff options
Diffstat (limited to 'tree.py')
-rw-r--r-- | tree.py | 64 |
1 files changed, 35 insertions, 29 deletions
@@ -2,64 +2,70 @@ import pygame from random import randint class Tree: - def __init__(self, surface, tree_color, window_h, window_w, position, tree_size, height, width): + def __init__(self, surface, position, tree_size): self.position = position - self.height = height - self.width = width + self.height = 10 + self.width = 10 + self.circle_w = randint (6,8) self.size = tree_size + self.circle1 = self.size * randint (1,2) + self.circle2 = self.size * randint (1,2) self.surface = surface - self.color = tree_color - pygame.draw.rect( self.surface, self.color, \ + self.color_circle = (randint(0,3), randint(100,200), randint(0,3)) + self.color_rect = (5, randint(100,200), 5) + + def draw(self): + pygame.draw.rect( self.surface, self.color_rect, \ ( (self.position[0] - self.height/2), \ (self.position[1] - self.width/2), \ self.size, \ self.size), \ 0) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0] + self.height/2), \ (self.position[1] + self.width/2)), \ - self.size*randint(1,2), \ - 8) + self.circle1, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0]), \ (self.position[1] + self.width/2)), \ - tree_size*randint(1,2), \ - 1) + self.circle2, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0] + self.height/2), \ (self.position[1])), \ - tree_size*randint(1,2), \ - 8) + self.circle1, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0] - self.height/2), \ (self.position[1] - self.width/2)), \ - tree_size*randint(1,2), \ - 8) + self.circle2, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0]), \ (self.position[1] - self.width/2)), \ - tree_size*randint(1,2), \ - 8) + self.circle1, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0] - self.height/2), \ (self.position[1])), \ - tree_size*randint(1,2), \ - 8) + self.circle2, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0] + self.height/2), \ (self.position[1]) - self.width/2), \ - tree_size*randint(1,2), \ - 8) + self.circle1, \ + self.circle_w) - pygame.draw.circle(self.surface, self.color, \ + pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0] - self.height/2), \ (self.position[1]) + self.width/2), \ - tree_size*randint(1,2), \ - 8) + self.circle2, \ + self.circle_w) |