1
1
# memory.py
2
+ # Created by Salvatore aka artyprog
3
+ # Improved by Jacque de Hooge aka JdeH
2
4
# This file is translated to Javascript using Transcrypt
3
5
4
6
colors = [JS .rgb2hex ("rgba({}, 0)" .format (color )) for color in [
12
14
(255 , 255 , 255 )
13
15
]]
14
16
17
+ # Future version of Transcrypt will allow [allcolors] * 2
15
18
allcolors = [color for tuplecolor in zip (colors , colors ) for color in tuplecolor ]
19
+
20
+ # JS.* -> Javascript Functions
16
21
JS .shuffle (allcolors )
17
22
18
- # Helper Functions:
23
+ # Helper Functions
19
24
def all (iterable ):
20
25
for element in iterable :
21
26
if not element :
@@ -51,7 +56,7 @@ def display(self):
51
56
sprite .content = color
52
57
sprite .showed = False
53
58
54
- # Backface
59
+ # Backface (Thanks JdeH)
55
60
rectb = self .game .rectangle (128 , 128 , "lightGray" )
56
61
rectb .x = posx
57
62
rectb .y = posy
@@ -64,6 +69,7 @@ def display(self):
64
69
# Gestion du Jeu
65
70
class Memory :
66
71
def __init__ (self , width = 524 , height = 524 ):
72
+ # Initialisation of the Game
67
73
self .game = hexi (width , height , self .setup )
68
74
self .game .backgroundColor = "seaGreen"
69
75
self .mouse = self .game .pointer
@@ -104,7 +110,7 @@ def _reset():
104
110
105
111
cella , cellb = self .clickedcells [:2 ]
106
112
if cella .num == cellb .num :
107
- self .clickedcells = self .clickedcells [:1 ]
113
+ self .clickedcells = self .clickedcells [:1 ] #JdeH
108
114
return
109
115
else :
110
116
icella , jcella = cella .num % numcols , cella .num // numrows
@@ -122,7 +128,7 @@ def _reset():
122
128
spriteb .showed = True
123
129
self .clickedcells = []
124
130
125
- def check_endgame (self ):
131
+ def check_endgame (self ): #JdeH
126
132
def endgame ():
127
133
for s in lst_spr :
128
134
s .alpha = 0
@@ -133,7 +139,7 @@ def endgame ():
133
139
lst_spr = [sprite for liste_sprites in self .grid .spr for sprite in liste_sprites ]
134
140
showed_values = [s .showed for s in lst_spr ]
135
141
if all (showed_values ):
136
- setTimeout (endgame , 2000 )
142
+ setTimeout (endgame , 2000 ) #JdeH
137
143
138
144
def play (self ):
139
145
self .check_endgame ()
0 commit comments