Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ripexz committed Feb 24, 2020
1 parent b03b81b commit 4d4dffa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions minesweeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def __init__(self, master):

#add mine and count at the end
self.label2 = Label(frame, text = "Mines: "+str(self.mines))
self.label2.grid(row = 11, column = 0, columnspan = 5)
self.label2.grid(row = SIZE_X+1, column = 0, columnspan = SIZE_Y/2)

self.label3 = Label(frame, text = "Flags: "+str(self.flags))
self.label3.grid(row = 11, column = 4, columnspan = 5)
self.label3.grid(row = SIZE_X+1, column = SIZE_Y/2-1, columnspan = SIZE_Y/2)

## End of __init__

Expand Down Expand Up @@ -153,7 +153,7 @@ def rclicked(self, button_data):
elif button_data["state"] == 2:
button_data["widget"].config(image = self.tiles["plain"])
button_data["state"] = 0
button_data["widget"].bind(BTN_CLICK, self.lclicked_wrapper(button_data["coords"][x], button_data["coords"][y]))
button_data["widget"].bind(BTN_CLICK, self.lclicked_wrapper(button_data["coords"]["x"], button_data["coords"]["y"]))
# if a mine
if button_data["isMine"] == True:
self.correct_flags -= 1
Expand Down Expand Up @@ -191,7 +191,7 @@ def clear_empty_tiles(self, id):
self.check_tile(source_x+1, source_y, queue) #bottom middle
self.check_tile(source_x+1, source_y+1, queue) #bottom left

def gameover(self):
def reveal(self):
for x in range(0, SIZE_X):
for y in range(0, SIZE_Y):
if self.buttons[x][y]["isMine"] == False and self.buttons[x][y]["state"] == STATE_FLAGGED:
Expand All @@ -200,12 +200,15 @@ def gameover(self):
self.buttons[x][y]["widget"].config(image = self.tiles["mine"])
global root
root.update()

def gameover(self):
self.reveal()
tkMessageBox.showinfo("Game Over", "You Lose!")
global root
root.destroy()

def victory(self):
global root
root.update()
self.reveal()
tkMessageBox.showinfo("Game Over", "You Win!")
root.destroy()

Expand Down

0 comments on commit 4d4dffa

Please sign in to comment.