MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/578808_Python_Game_of_Life/recipe-578808.py:10–50  ·  view source on GitHub ↗
(self, game, pos, num)

Source from the content-addressed store, hash-verified

8
9class Cell(pygame.sprite.Sprite):
10 def __init__(self, game, pos, num):
11 pygame.sprite.Sprite.__init__(self)
12
13 self.game = game
14
15 self.num = num
16 self.color = self.getColor()
17
18 self.parent = 0
19
20 self.image = pygame.Surface([10,10])
21 self.image.fill((0,0,0))
22 self.rect = self.image.get_rect()
23 self.rect.topleft = pos
24
25 self.alive = False
26 self.edge = False
27
28 self.a_neighbors = []
29 self.d_neighbors = []
30
31 self.n = (num - 74) - 1
32 self.e = (num + 1) - 1
33 self.s = (num + 74) - 1
34 self.w = (num - 1) - 1
35 self.ne = (self.n + 1)
36 self.se = (self.s + 1)
37 self.nw = (self.n - 1)
38 self.sw = (self.s - 1)
39
40 self.cell_list = [
41 self.n,
42 self.e,
43 self.s,
44 self.w,
45 self.ne,
46 self.se,
47 self.nw,
48 self.sw]
49
50 self.game.cells.append(self)
51 def getColor(self):
52 value = [i for i in range(100,255,25)]
53 r = random.choice(value)

Callers

nothing calls this directly

Calls 3

getColorMethod · 0.95
fillMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected