Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo D. Arce S <rodolfo.arce.s@gmail.com>2011-05-18 23:07:58 (GMT)
committer Rodolfo D. Arce S <rodolfo.arce.s@gmail.com>2011-05-18 23:07:58 (GMT)
commitb2afd587b570c9588047fda93e4526bae100faaf (patch)
tree94937b4df857164abf840bb3b493f3f8cf6d16f1
parentad5bf77a313a963a5dae1058358d98744c6884e0 (diff)
Added different colors for trees, draw many of them in the area
-rw-r--r--main.py27
-rw-r--r--tree.py32
2 files changed, 34 insertions, 25 deletions
diff --git a/main.py b/main.py
index 9217f65..f6e1dac 100644
--- a/main.py
+++ b/main.py
@@ -17,7 +17,24 @@ tree_height = tree_width = 40
tree_radius = 15
#clock = pygame.time.Clock()
+
+
+# Draw background
+screen.fill(bg_color)
+# Draw everything on top of that
+number_trees = 160
+while number_trees != 0:
+ Tree(screen, \
+ (randint(0,5), randint(0,255), randint(0,5) ), \
+ window_h, \
+ window_w, \
+ (randint(0,window_h), randint(0,window_w)) , 15, 20, 20)
+ number_trees -=1
+
+
+
+
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
@@ -26,14 +43,6 @@ while True:
keyboard = pygame.key.get_pressed()
if keyboard[K_ESCAPE]:
exit()
-
- # Draw background
- screen.fill(bg_color)
-
- # Draw everything on top of that
- #pygame.draw.circle(screen, tree_color, (window_h/2, window_w/2), tree_radius, 0)
- Tree(screen, tree_color, window_h, window_w, (window_h/2, window_w/2) , 20, 10, 10)
-
-
+
pygame.display.update()
#clock.tick(60)
diff --git a/tree.py b/tree.py
index ca6a0eb..d6f2940 100644
--- a/tree.py
+++ b/tree.py
@@ -19,47 +19,47 @@ class Tree:
pygame.draw.circle(self.surface, self.color, \
((self.position[0] + self.height/2), \
(self.position[1] + self.width/2)), \
- self.size/randint(1,2), \
- 0)
+ self.size*randint(1,2), \
+ 8)
pygame.draw.circle(self.surface, self.color, \
((self.position[0]), \
(self.position[1] + self.width/2)), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 1)
pygame.draw.circle(self.surface, self.color, \
((self.position[0] + self.height/2), \
(self.position[1])), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 8)
pygame.draw.circle(self.surface, self.color, \
((self.position[0] - self.height/2), \
(self.position[1] - self.width/2)), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 8)
pygame.draw.circle(self.surface, self.color, \
((self.position[0]), \
(self.position[1] - self.width/2)), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 8)
pygame.draw.circle(self.surface, self.color, \
((self.position[0] - self.height/2), \
(self.position[1])), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 8)
pygame.draw.circle(self.surface, self.color, \
((self.position[0] + self.height/2), \
(self.position[1]) - self.width/2), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 8)
pygame.draw.circle(self.surface, self.color, \
((self.position[0] - self.height/2), \
(self.position[1]) + self.width/2), \
- tree_size/randint(1,2), \
- 0)
+ tree_size*randint(1,2), \
+ 8)