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 22:43:53 (GMT)
committer Rodolfo D. Arce S <rodolfo.arce.s@gmail.com>2011-05-18 22:43:53 (GMT)
commitad5bf77a313a963a5dae1058358d98744c6884e0 (patch)
treedfc0a5f6d13e682180a4d8118dda2eadaf8d4293
parentdecfae19d747f765de74647dc07f82f65e8ab776 (diff)
Cleaned some of the tree class, still has issues
-rw-r--r--main.py11
-rw-r--r--tree.py34
2 files changed, 21 insertions, 24 deletions
diff --git a/main.py b/main.py
index c6699d8..9217f65 100644
--- a/main.py
+++ b/main.py
@@ -6,16 +6,13 @@ from tree import Tree
window_h = 640
window_w = 480
+# Background
+bg_color = [204, 102, 0]
screen = pygame.display.set_mode( (window_h, window_w) )
pygame.display.set_caption("Ranger")
-tree = Tree(screen, window_h, window_w, (window_h/2, window_w/2), 15, 20, 20)
-
# Tree
-global tree_color
-global bg_color
tree_color = [51, 204, 0]
-bg_color = [204, 102, 0]
tree_height = tree_width = 40
tree_radius = 15
@@ -34,9 +31,9 @@ while True:
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()
+ pygame.display.update()
#clock.tick(60)
diff --git a/tree.py b/tree.py
index 8136198..ca6a0eb 100644
--- a/tree.py
+++ b/tree.py
@@ -1,65 +1,65 @@
import pygame
-import random
+from random import randint
class Tree:
- def __init__(self, surface, window_h, window_w, position, tree_size, height, width):
+ def __init__(self, surface, tree_color, window_h, window_w, position, tree_size, height, width):
self.position = position
self.height = height
self.width = width
self.size = tree_size
- self.surface = surface
-
- pygame.draw.rect( self.surface, tree_color, \
+ self.surface = surface
+ self.color = tree_color
+ pygame.draw.rect( self.surface, self.color, \
( (self.position[0] - self.height/2), \
(self.position[1] - self.width/2), \
self.size, \
self.size), \
0)
- pygame.draw.circle(self.surface, tree_color, \
+ 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)
-
- pygame.draw.circle(self.surface, tree_color, \
+
+ pygame.draw.circle(self.surface, self.color, \
((self.position[0]), \
(self.position[1] + self.width/2)), \
tree_size/randint(1,2), \
0)
- pygame.draw.circle(self.surface, tree_color, \
- ((self.position[0] + selfheight/2), \
+ pygame.draw.circle(self.surface, self.color, \
+ ((self.position[0] + self.height/2), \
(self.position[1])), \
tree_size/randint(1,2), \
0)
- pygame.draw.circle(self.surface, tree_color, \
+ 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)
- pygame.draw.circle(self.surface, tree_color, \
+ pygame.draw.circle(self.surface, self.color, \
((self.position[0]), \
- (self.position[1] - tree_width/2)), \
+ (self.position[1] - self.width/2)), \
tree_size/randint(1,2), \
0)
- pygame.draw.circle(self.surface, tree_color, \
+ pygame.draw.circle(self.surface, self.color, \
((self.position[0] - self.height/2), \
(self.position[1])), \
tree_size/randint(1,2), \
0)
- pygame.draw.circle(self.surface, tree_color, \
+ 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)
- pygame.draw.circle(self.surface, tree_color, \
+ 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) \ No newline at end of file
+ 0)