@@ -199,18 +199,6 @@ def leftclick(self, pos) -> bool:
199
199
self ._zero_search (tile , searched )
200
200
return True
201
201
202
- def show_mines (self ):
203
- if not self ._revealed :
204
- self ._revealed = True
205
-
206
- for pos in self .mines :
207
- px , py = pos
208
- tile = self .grid [px ][py ]
209
- if pos not in self .flags :
210
- tile .toggle_visible ()
211
- else :
212
- tile .set_green ()
213
-
214
202
def _zero_search (self , tile , searched ):
215
203
if tile .n != 0 :
216
204
return searched
@@ -230,6 +218,18 @@ def _zero_search(self, tile, searched):
230
218
231
219
return searched
232
220
221
+ def show_mines (self ):
222
+ if not self ._revealed :
223
+ self ._revealed = True
224
+
225
+ for pos in self .mines :
226
+ px , py = pos
227
+ tile = self .grid [px ][py ]
228
+ if pos not in self .flags :
229
+ tile .toggle_visible ()
230
+ else :
231
+ tile .set_green ()
232
+
233
233
def __init__ (self , x , y , mines : int ):
234
234
self .x = x
235
235
self .y = y
@@ -242,9 +242,9 @@ def __init__(self, x, y, mines: int):
242
242
y_blocks = y * BLOCK_SIZE
243
243
244
244
self .tl = (GRIDPADDING , GRIDPADDING )
245
- self .tr = (GRIDPADDING , GRIDPADDING + x_blocks )
246
- self .bl = (GRIDPADDING + y_blocks , GRIDPADDING )
247
- self .br = (GRIDPADDING + y_blocks , GRIDPADDING + x_blocks )
245
+ self .tr = (GRIDPADDING , GRIDPADDING + y_blocks )
246
+ self .bl = (GRIDPADDING + x_blocks , GRIDPADDING )
247
+ self .br = (GRIDPADDING + x_blocks , GRIDPADDING + y_blocks )
248
248
249
249
def _construct_grid (self , x , y , first_pos ):
250
250
exclude = {pos for pos in _around (first_pos )}
@@ -293,11 +293,13 @@ def render(self, win):
293
293
294
294
# Outline
295
295
for i in range (0 , self .x + 1 ):
296
- left = add (self .tl , (i * 16 , 0 ))
297
- right = add (self .tr , (i * 16 , 0 ))
296
+ diff = (i * 16 , 0 )
297
+ left = add (self .tl , diff )
298
+ right = add (self .tr , diff )
298
299
pygame .draw .line (win , colours .BLACK , left , right , 1 )
299
300
300
301
for i in range (0 , self .y + 1 ):
301
- top = add (self .tl , (0 , i * 16 ))
302
- bottom = add (self .bl , (0 , i * 16 ))
302
+ diff = (0 , i * 16 )
303
+ top = add (self .tl , diff )
304
+ bottom = add (self .bl , diff )
303
305
pygame .draw .line (win , colours .BLACK , top , bottom , 1 )
0 commit comments