@@ -100,7 +100,6 @@ def compute_counts():
100100 for x in range (20 ):
101101 if get_data (x , y ) != 14 :
102102 continue # keep looking for bombs
103- print ('found bomb at %d, %d' % (x , y ))
104103 for dx in (- 1 , 0 , 1 ):
105104 if x + dx < 0 or x + dx >= 20 :
106105 continue # off screen
@@ -158,33 +157,6 @@ def check_for_win():
158157 return False #misflagged bombs, not done
159158 return True #nothing unexplored, and no misflagged bombs
160159
161- # comment or remove if not using screenshots ######################
162- #pylint:disable=global-statement
163- # from adafruit_bitmapsaver import save_pixels #
164- # from adafruit_debouncer import Debouncer #
165- # import busio #
166- # import adafruit_sdcard #
167- # import storage #
168- # spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) #
169- # cs = digitalio.DigitalInOut(board.SD_CS) #
170- # sdcard = adafruit_sdcard.SDCard(spi, cs) #
171- # vfs = storage.VfsFat(sdcard) #
172- # storage.mount(vfs, "/sd") #
173- # snapshot_switch = digitalio.DigitalInOut(board.D4) #
174- # snapshot_switch.direction = digitalio.Direction.INPUT #
175- # snapshot_switch.pull= digitalio.Pull.UP #
176- # snapshot = Debouncer(snapshot_switch) #
177- # screenshot_number = 1 #
178- # #
179- # def make_new_screenshot(): #
180- # global screenshot_number #
181- # print('Taking /sd/screenshot_%d.bmp' % (screenshot_number)) #
182- # save_pixels('/sd/screenshot_%d.bmp' % (screenshot_number)) #
183- # print('Finished taking scheenshot.') #
184- # screenshot_number += 1 #
185- #pylint:enable=global-statement
186- ###################################################################
187-
188160def play_a_game ():
189161 number_uncovered = 0
190162 touch_x = - 1
@@ -193,10 +165,6 @@ def play_a_game():
193165 wait_for_release = False
194166 while True :
195167 now = time .monotonic ()
196- # snapshot.update()
197- # if snapshot.fell:
198- # make_new_screenshot()
199- # continue
200168 if now >= touch_time :
201169 touch_time = now + 0.2
202170 # process touch
@@ -209,15 +177,15 @@ def play_a_game():
209177 wait_for_release = True
210178 touch_x = max (min ([touch_at [0 ] // 16 , 19 ]), 0 )
211179 touch_y = max (min ([touch_at [1 ] // 16 , 14 ]), 0 )
212- print ('Touched (%d, %d)' % (touch_x , touch_y ))
213180 if tilegrid [touch_x , touch_y ] == BLANK :
214181 tilegrid [touch_x , touch_y ] = BOMBQUESTION
215182 elif tilegrid [touch_x , touch_y ] == BOMBQUESTION :
216183 tilegrid [touch_x , touch_y ] = BOMBFLAGGED
217184 elif tilegrid [touch_x , touch_y ] == BOMBFLAGGED :
218185 under_the_tile = get_data (touch_x , touch_y )
219186 if under_the_tile == 14 :
220- set_data (touch_x , touch_y , BOMBDEATH )
187+ set_data (touch_x , touch_y , BOMBDEATH ) #this will casue a red bomb to be revealed
188+ tilegrid [touch_x , touch_y ] = BOMBDEATH
221189 return False #lost
222190 elif under_the_tile > OPEN0 and under_the_tile <= OPEN8 :
223191 tilegrid [touch_x , touch_y ] = under_the_tile
@@ -255,12 +223,10 @@ def wait_for_sound_and_cleanup(wavfile):
255223
256224def win ():
257225 print ('You won' )
258- # make_new_screenshot()
259226 wait_for_sound_and_cleanup (play_sound ('win.wav' ))
260227
261228def loose ():
262229 print ('You lost' )
263- # make_new_screenshot()
264230 wavfile = play_sound ('loose.wav' )
265231 for _ in range (10 ):
266232 tilegrid .x = randint (- 2 , 2 )
0 commit comments