Skip to content

Commit f8980c8

Browse files
committed
v0.1.3 can remove flags, flagged tiles are unbound and safe to click on
1 parent 6d35e62 commit f8980c8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

minesweeper.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def __init__(self, master):
3838
# 0 = Button
3939
# 1 = if a mine y/n (1/0)
4040
# 2 = state (0 = unclicked, 1 = clicked, 2 = flagged)
41-
self.buttons[x] = [ Button(frame, image = gfx), mine, 0 ]
41+
# 3 = button id
42+
self.buttons[x] = [ Button(frame, image = gfx), mine, 0, x ]
4243
self.buttons[x][0].bind('<Button-1>', self.lclicked_wrapper(x))
4344
self.buttons[x][0].bind('<Button-3>', self.rclicked_wrapper(x))
4445

@@ -83,6 +84,12 @@ def rclicked(self, button_data):
8384
if button_data[2] == 0:
8485
button_data[0].config(image = self.tile_flag)
8586
button_data[2] = 2
87+
button_data[0].unbind('<Button-1>')
88+
# if flagged, unflag
89+
elif button_data[2] == 2:
90+
button_data[0].config(image = self.tile_plain)
91+
button_data[2] = 0
92+
button_data[0].bind('<Button-1>', self.lclicked_wrapper(button_data[3]))
8693

8794
def gameover(self):
8895
tkMessageBox.showinfo("Game Over", "You Lose!")

0 commit comments

Comments
 (0)