cb0c3b3e4aa1313ae2e1c770177fd1890b42d8da
[e-sieve] / scale_sieve / ScaleSieve.py
1 from pygame import Surface, PixelArray
2
3 from scale_sieve.pgfw.Game import Game
4 from scale_sieve.pgfw.GameChild import GameChild
5 from scale_sieve.pgfw.Sprite import Sprite
6
7 class ScaleSieve(Game):
8
9 def __init__(self):
10 Game.__init__(self)
11 self.background = Surface(self.display.screen.get_size())
12 self.background.fill((255, 80, 190))
13
14 def set_children(self):
15 Game.set_children(self)
16 self.sieve = Sieve(self)
17
18 def update(self):
19 self.display.screen.blit(self.background, (0, 0))
20 self.sieve.update()
21
22
23 class Strip(Sprite):
24
25 def __init__(self, parent):
26 Sprite.__init__(self, parent)
27 self.display_surface = self.get_display_surface()
28 self.add_frames()
29
30 def add_frames(self):
31 pass
32
33
34 class Sieve(Strip):
35
36 def __init__(self, parent):
37 Strip.__init__(self, parent)
38 self.location.center = self.display_surface.get_rect().center
39
40 def add_frames(self):
41 surface = Surface((1000, 30))
42 transparent_color = (255, 0, 255)
43 surface.fill(transparent_color)
44 surface.set_colorkey(transparent_color)
45 frames = surface, surface.copy()
46 background_colors = (255, 255, 0), (0, 0, 213)
47 divider_colors = (0, 255, 0), (153, 0, 204)
48 pixel_arrays = PixelArray(frames[0]), PixelArray(frames[1])
49 bw = 5
50 for x in xrange(len(pixel_arrays[0])):
51 for y in xrange(bw, len(pixel_arrays[0][0]) - bw):
52 pixel_arrays[0][x][y] = background_colors[(y + x) % 2]
53 pixel_arrays[1][x][y] = background_colors[(y + x + 1) % 2]
54 for pixels in pixel_arrays:
55 del pixels
56 for frame in frames:
57 self.add_frame(frame)