triangle
authorFrank DeMarco <frank.s.demarco@gmail.com>
Sat, 26 Apr 2014 03:18:47 +0000 (12:18 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Sat, 26 Apr 2014 03:18:47 +0000 (12:18 +0900)
scale_sieve/ScaleSieve.py

index d96640a..e5eb8c3 100644 (file)
@@ -1,6 +1,8 @@
 from random import randint, randrange, choice
 
 from pygame import Surface, PixelArray
+from pygame.draw import aalines, polygon
+from pygame.locals import *
 
 from scale_sieve.pgfw.Game import Game
 from scale_sieve.pgfw.GameChild import GameChild
@@ -173,7 +175,7 @@ class Triangle(Sprite):
 
     def __init__(self, parent):
         Sprite.__init__(self, parent)
-        mark = randint(64, 256)
+        mark = randint(72, 296)
         sieve = self.parent.parent.sieve
         gaps = sieve.gaps
         start = randrange(0, len(gaps))
@@ -181,16 +183,17 @@ class Triangle(Sprite):
         while sum(widths) < mark:
             widths.append(gaps[(start + len(widths)) % len(gaps)])
         surface = Surface((sum(widths), 20))
-        transparent_color = (255, 0, 255)
-        surface.fill(transparent_color)
-        surface.set_colorkey(transparent_color)
+        surface.set_colorkey((0, 0, 0))
         x = 0
-        margin = 6
+        height = surface.get_height()
+        margin = 10
         for width in widths:
-            surface.fill((102, 82, 99), (x + sieve.bar_w + margin / 2, 0,
-                                         width - sieve.bar_w - margin,
-                                         surface.get_height()))
-            x += width
+            x += sieve.bar_w
+            points = (x + margin / 2, height - 2), \
+                     (x + width - margin / 2 - 1, height - 2), \
+                     (x + width / 2.0, 1)
+            polygon(surface, (60, 255, 220), points)
+            x += width - sieve.bar_w
         self.add_frame(surface)
         self.location.centerx = self.get_display_surface().get_rect().centerx