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

Method update

recipes/Python/578808_Python_Game_of_Life/recipe-578808.py:65–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

63 self.alive = True
64
65 def update(self):
66 if not self.edge:
67 self.a_neighbors = []
68 self.d_neighbors = []
69 neighbors = [self.game.cells[cell] for cell in self.cell_list]
70
71 for n in neighbors:
72 if n.alive:
73 self.a_neighbors.append(True)
74 else:
75 self.d_neighbors.append(True)
76
77 if not self.game.running:
78
79 if pygame.mouse.get_pressed()[0] and self.rect.collidepoint(self.game.mpos):
80 self.alive = True
81 self.image.fill(self.color)
82
83 if pygame.mouse.get_pressed()[2] and self.rect.collidepoint(self.game.mpos)and self.alive:
84 self.image.fill((0,0,0))
85 self.alive = False
86 if self.alive:
87 self.image.fill(self.color)
88 else:
89 if self.alive:
90 self.image.fill(self.color)
91
92 if not self.alive:
93 self.image.fill((0, 0, 0))
94
95 else:
96 self.image.fill((255, 255, 255))
97
98
99

Callers 4

LoopMethod · 0.45
DrawMethod · 0.45
__init__Method · 0.45
configTrackColorsMethod · 0.45

Calls 2

fillMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected