Skip to content

Commit f249ae7

Browse files
authored
Update memory.py
1 parent 1f3f803 commit f249ae7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

memory/src/memory.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# memory.py
2+
# Created by Salvatore aka artyprog
3+
# Improved by Jacque de Hooge aka JdeH
24
# This file is translated to Javascript using Transcrypt
35

46
colors = [JS.rgb2hex("rgba({}, 0)".format (color)) for color in [
@@ -12,10 +14,13 @@
1214
(255, 255, 255)
1315
]]
1416

17+
# Future version of Transcrypt will allow [allcolors] * 2
1518
allcolors = [color for tuplecolor in zip(colors, colors) for color in tuplecolor]
19+
20+
# JS.* -> Javascript Functions
1621
JS.shuffle(allcolors)
1722

18-
# Helper Functions:
23+
# Helper Functions
1924
def all(iterable):
2025
for element in iterable:
2126
if not element:
@@ -51,7 +56,7 @@ def display(self):
5156
sprite.content = color
5257
sprite.showed = False
5358

54-
# Backface
59+
# Backface (Thanks JdeH)
5560
rectb = self.game.rectangle(128, 128, "lightGray")
5661
rectb.x = posx
5762
rectb.y = posy
@@ -64,6 +69,7 @@ def display(self):
6469
# Gestion du Jeu
6570
class Memory:
6671
def __init__(self, width=524, height=524):
72+
# Initialisation of the Game
6773
self.game = hexi(width, height, self.setup)
6874
self.game.backgroundColor = "seaGreen"
6975
self.mouse = self.game.pointer
@@ -104,7 +110,7 @@ def _reset():
104110

105111
cella, cellb = self.clickedcells[:2]
106112
if cella.num == cellb.num:
107-
self.clickedcells = self.clickedcells [:1]
113+
self.clickedcells = self.clickedcells [:1] #JdeH
108114
return
109115
else:
110116
icella, jcella = cella.num % numcols, cella.num // numrows
@@ -122,7 +128,7 @@ def _reset():
122128
spriteb.showed = True
123129
self.clickedcells = []
124130

125-
def check_endgame(self):
131+
def check_endgame(self): #JdeH
126132
def endgame ():
127133
for s in lst_spr:
128134
s.alpha = 0
@@ -133,7 +139,7 @@ def endgame ():
133139
lst_spr = [sprite for liste_sprites in self.grid.spr for sprite in liste_sprites]
134140
showed_values = [s.showed for s in lst_spr]
135141
if all(showed_values):
136-
setTimeout (endgame, 2000)
142+
setTimeout (endgame, 2000) #JdeH
137143

138144
def play(self):
139145
self.check_endgame()

0 commit comments

Comments
 (0)