Skip to content

Commit b4ac061

Browse files
committed
Various cleanup
1 parent f4d84f3 commit b4ac061

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

Minesweep/code.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@
5252
BOMBFLAGGED = 11
5353
BOMBMISFLAGGED = 12
5454
BOMBQUESTION = 13
55-
BOMBREVEALED = 14
5655
BOMB = 14
5756

58-
5957
sprite_sheet, palette = adafruit_imageload.load("/SpriteSheet.bmp",
6058
bitmap=displayio.Bitmap,
6159
palette=displayio.Palette)
@@ -72,9 +70,10 @@
7270
tile_height=16, tile_width=16,
7371
default_tile=BLANK)
7472
group.append(tilegrid)
75-
display.show(group)
7673

77-
DATA_BOMB = -1
74+
75+
76+
display.show(group)
7877

7978
board_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-
9088
def 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-
10097
def 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-
119115
def 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

125123
def 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-
148145
def 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

Comments
 (0)