Skip to content

Commit 714e8e1

Browse files
author
Serdar Yegulalp
committed
don't use globals for color settings either
1 parent 32d0ef5 commit 714e8e1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/conway.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@
6262

6363
all_colors = [basic, green_shades, rainbow_colors, cga1, cga2, cga3]
6464

65-
colors = 0
66-
6765

6866
class MyWindow(pyglet.window.Window):
6967
def __init__(self, *a, **ka):
7068
super().__init__(*a, **ka)
71-
self.game_obj = Life(WIDTH, HEIGHT, all_colors[colors])
69+
70+
self.colors = 0
71+
self.game_obj = Life(WIDTH, HEIGHT, all_colors[self.colors])
7272

7373
self.framerate = FRAMERATE
7474
self.randomization_factor = FACTOR
@@ -138,9 +138,8 @@ def on_key_press(self, symbol, modifiers):
138138

139139
elif symbol in (91, 93):
140140
direction = symbol - 92
141-
global colors
142-
colors = (colors + direction) % len(all_colors)
143-
self.game_obj.set_colors(all_colors[colors])
141+
self.colors = (self.colors + direction) % len(all_colors)
142+
self.game_obj.set_colors(all_colors[self.colors])
144143
if not self.running:
145144
self.on_draw()
146145
elif symbol == 32:

0 commit comments

Comments
 (0)