5252BOMBFLAGGED = 11
5353BOMBMISFLAGGED = 12
5454BOMBQUESTION = 13
55- BOMBREVEALED = 14
5655BOMB = 14
5756
58-
5957sprite_sheet , palette = adafruit_imageload .load ("/SpriteSheet.bmp" ,
6058 bitmap = displayio .Bitmap ,
6159 palette = displayio .Palette )
7270 tile_height = 16 , tile_width = 16 ,
7371 default_tile = BLANK )
7472group .append (tilegrid )
75- display .show (group )
7673
77- DATA_BOMB = - 1
74+
75+
76+ display .show (group )
7877
7978board_data = bytearray (b'\x00 ' * 300 )
8079
@@ -86,7 +85,6 @@ def set_data(x, y, value):
8685 board_data [y * 20 + x ] = value
8786#pylint:disable=redefined-outer-name
8887
89-
9088def seed_bombs (how_many ):
9189 for _ in range (how_many ):
9290 while True :
@@ -96,7 +94,6 @@ def seed_bombs(how_many):
9694 set_data (bomb_x , bomb_y , 14 )
9795 break
9896
99-
10097def compute_counts ():
10198 """For each bomb, increment the count in each non-bomb square around it"""
10299 for y in range (15 ):
@@ -115,12 +112,13 @@ def compute_counts():
115112 continue # don't process bombs
116113 set_data (x + dx , y + dy , count + 1 )
117114
118-
119115def reveal ():
120116 for x in range (20 ):
121117 for y in range (15 ):
122- tilegrid [x , y ] = get_data (x , y )
123-
118+ if tilegrid [x , y ] == BOMBFLAGGED and get_data (x , y ) != BOMB :
119+ tilegrid [x , y ] = BOMBMISFLAGGED
120+ else :
121+ tilegrid [x , y ] = get_data (x , y )
124122
125123def expand_uncovered (start_x , start_y ):
126124 number_uncovered = 1
@@ -144,7 +142,6 @@ def expand_uncovered(start_x, start_y):
144142 stack .append ((x + dx , y + dy ))
145143 return number_uncovered
146144
147-
148145def check_for_win ():
149146 """Check for a complete, winning game. That's one with all squares uncovered
150147 and all bombs correctly flagged, with no non-bomb squares flaged.
0 commit comments