diff options
author | Rodolfo D. Arce S <rodolfo.arce.s@gmail.com> | 2011-05-19 23:12:41 (GMT) |
---|---|---|
committer | Rodolfo D. Arce S <rodolfo.arce.s@gmail.com> | 2011-05-19 23:12:41 (GMT) |
commit | 5cfd98840092baf5903308c5e0a084f93a5cf20e (patch) | |
tree | 27801aea57588f1554218d4c7b5a22823a3eeeac | |
parent | 7e2c99eac909d717fa6265361452eb3ded8d3acc (diff) |
Tree trunk is different from branches, improved colors
-rw-r--r-- | tree.py | 77 |
1 files changed, 39 insertions, 38 deletions
@@ -4,68 +4,69 @@ from random import randint class Tree: def __init__(self, surface, position, tree_size): self.position = position - self.height = 10 - self.width = 10 - self.circle_w = randint (6,8) + self.rect_height = tree_size + self.rect_width = tree_size + self.circle_w1 = randint (8,10) + self.circle_w2 = randint (8,10) self.size = tree_size self.circle1 = self.size * randint (1,2) self.circle2 = self.size * randint (1,2) self.surface = surface self.color_circle = (randint(0,3), randint(100,200), randint(0,3)) - self.color_rect = (5, randint(100,200), 5) + self.color_rect = (10, (self.color_circle[1] + 20), 10) 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_circle, \ - ((self.position[0] + self.height/2), \ - (self.position[1] + self.width/2)), \ + ((self.position[0] - self.rect_height/2), \ + (self.position[1] - self.rect_width/2)), \ self.circle1, \ - self.circle_w) + self.circle_w2) + + pygame.draw.circle(self.surface, self.color_circle, \ + ((self.position[0] + self.rect_height/2), \ + (self.position[1] + self.rect_width/2)), \ + self.circle1, \ + self.circle_w2) pygame.draw.circle(self.surface, self.color_circle, \ ((self.position[0]), \ - (self.position[1] + self.width/2)), \ + (self.position[1] - self.rect_width/2)), \ self.circle2, \ - self.circle_w) - + self.circle_w1) + pygame.draw.circle(self.surface, self.color_circle, \ - ((self.position[0] + self.height/2), \ - (self.position[1])), \ + ((self.position[0]), \ + (self.position[1] + self.rect_width/2)), \ self.circle1, \ - self.circle_w) - + self.circle_w2) + pygame.draw.circle(self.surface, self.color_circle, \ - ((self.position[0] - self.height/2), \ - (self.position[1] - self.width/2)), \ - self.circle2, \ - self.circle_w) - - pygame.draw.circle(self.surface, self.color_circle, \ - ((self.position[0]), \ - (self.position[1] - self.width/2)), \ + ((self.position[0] + self.rect_height/2), \ + (self.position[1])), \ self.circle1, \ - self.circle_w) + self.circle_w2) pygame.draw.circle(self.surface, self.color_circle, \ - ((self.position[0] - self.height/2), \ + ((self.position[0] - self.rect_height/2), \ (self.position[1])), \ self.circle2, \ - self.circle_w) + self.circle_w1) pygame.draw.circle(self.surface, self.color_circle, \ - ((self.position[0] + self.height/2), \ - (self.position[1]) - self.width/2), \ + ((self.position[0] + self.rect_height/2), \ + (self.position[1]) - self.rect_width/2), \ self.circle1, \ - self.circle_w) + self.circle_w2) pygame.draw.circle(self.surface, self.color_circle, \ - ((self.position[0] - self.height/2), \ - (self.position[1]) + self.width/2), \ + ((self.position[0] - self.rect_height/2), \ + (self.position[1]) + self.rect_width/2), \ self.circle2, \ - self.circle_w) + self.circle_w1) + + pygame.draw.rect( self.surface, self.color_rect, \ + ( (self.position[0]), \ + (self.position[1]), \ + self.size, \ + self.size), \ + 0) |