1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
from random import *
from tkinter import *
import webbrowser
from tkinter import messagebox
from time import sleep
# fenetre démineur
fenetre = Tk()
fenetre.title("démineur")
fenetre.geometry("430x465")
fenetre.minsize(410, 465)
fenetre.config(background='#FFFFFF')
# fenetre1
window = Tk()
window.title("démineur")
window.geometry("1080x720")
window.minsize(1080, 720)
window.iconbitmap("démineur.ico")
window.config(background='#FFFFFF')
#fenetre score board
score_board = Tk()
score_board.title("démineur")
score_board.geometry("1080x720")
score_board.minsize(1080, 720)
score_board.iconbitmap("démineur.ico")
score_board.config(background='#FFFFFF')
#sous fentre 1
frame = Frame(window, bg='#FFFFFF')
def open_github():
webbrowser.open_new("https://github.com")
def fermer_fenetre():
window.quit()
sleep(1)
fenetre.mainloop()
# fenetre 1 bouton et texte
textedebut = Label(frame, text="bienvenue sur le démineur", font=("Courrier", 40), bg='#FFFFFF')
textedebut.pack(expand=YES)
credit = Label(frame, text="réaliser par Olivier", font=("Courrier", 20), bg='#FFFFFF')
credit.pack(expand=YES)
gt_buttion = Button(frame, text="ouvrir github", font=("Courrier", 20), bg='#FFFFFF', command=open_github)
gt_buttion.pack(side=BOTTOM, pady=100)
quit_buttion = Button(frame, text="quitter crédit", font=("Courrier", 20), bg='#FFFFFF', command=fermer_fenetre)
quit_buttion.pack(side=BOTTOM, pady=50)
frame.pack(expand=YES)
#position mine
xmin1 = randint(0, 18)
ymin1 = randint(0, 9)
xmin2 = randint(0, 18)
ymin2 = randint(0, 9)
xmin3 = randint(0, 19)
ymin3 = randint(0, 9)
xmin4 = randint(0, 18)
ymin4 = randint(0, 9)
print(xmin1,ymin1,xmin2,ymin2,xmin3,ymin3,xmin4,ymin4)
nb = 1
tab=[Button]*200
score=0
#score ( case déactiver avant de toucher une mine )
def point():
global score
score=score+1
return score
# affiche score précédant dans scoreboard
def score_precedent():
with open("score.txt","a+") as file:
nb_ligne= file.readlines()
tab_score = [0]*len(nb_ligne)
for x in range(len(nb_ligne)):
tab_score[x]=int(file.read())
print(nb_ligne,"&bc")
tab_score.sort(reverse = True)
for p in range(len(nb_ligne)):
scoreint=str(tab_score)
Label(score_board,text="{} avec le score de {}".format(p,scoreint))
file.close()
score_precedent()
def minetoucher():
print("vous avez perdu")
global score
messagebox.showerror(title="démineur", message=" tu as perdu \n partie termier !\n ton score est de {}".format(score))
sleep(5)
score=str(score)
with open("score.txt","a+") as file:
file.write(score+ "\n")
print(score)
file.close()
window.destroy()
fenetre.destroy()
return 0
tabnb=[[0,0]]*191
tabm=[0]*191
i=1
z=1
e=1
def disparait(i):
tab[i]['text']='rien'
def change_nom_proche(none):
globals()
none.config(text="proche")
#def change_nom_rien(i):
# globals()
# tab[i]['text'] = 'rien'
# programe vérifie case a changer en text= rien ou a détruire (non fonctionelle)
#e=64
#while 1==0:
# if e<64 or e=None:
# e=0
# zz=0
# xx=0
# if tabm[e]==1:
# i=i
# elif tabm[e+1] or tabm[e-1]:
# i=i
# elif tabnb[e][0] == xmin1 and tabnb[e][1] == ymin1 or tabnb[e][0] == xmin2 and tabnb[e][1] == ymin2 or tabnb[e[0] == xmin3 and tabnb[e][1] == ymin3 or tabnb[e][0] == xmin4 and tabnb[e][1] == ymin4:
# zz=tabnb[e][1]
# xx=tabnb[e][1]
# tab[e]=Button(fenetre, text="proche").grid(row=lignee, column=colonnee)
# else:
# tab[e].destroy()
# if e>85:
# e=64
# else:
# e=e+1
tabe=[0]*200
# creation grille button dans une matrice
i=1
for ligne in range(19):
for colonne in range(10):
if ligne == xmin1 and colonne == ymin1 or ligne == xmin2 and colonne == ymin2 or ligne == xmin3 and colonne == ymin3 or ligne == xmin4 and colonne == ymin4:
tab[i]=Button(fenetre, text="mine0", command=minetoucher,bg='#111111').grid(row=ligne, column=colonne)
tabnb[i][0]=ligne
tabnb[i][1]=colonne
tabm[i]=1
print("a", i)
elif ligne == xmin1 - 1 or ligne == xmin1 + 1 and colonne == ymin1 - 1 or colonne == ymin1 + 1 and ligne == xmin2 - 1 or ligne == xmin2 + 1 and colonne == ymin2 - 1 or colonne == ymin2 + 1 and ligne == xmin3 - 1 or ligne == xmin3 + 1 and colonne == ymin3 - 1 or colonne == ymin3 + 1 and ligne == xmin4 - 1 or ligne == xmin4 + 1 and colonne == ymin4 - 1 or colonne == ymin4 + 1:
tab[i]=Button(fenetre, text="mine?",command=lambda :change_nom_proche(i) and point).grid(row=ligne, column=colonne)
tabnb[i][0] = ligne
tabnb[i][1] = colonne
print("2",i)
else:
tab[i] = Button(fenetre, text="mine?", command=none.config(text="rien") and point).grid(row=ligne, column=colonne)
print(i)
i=i+1
z=z+1
nb += 1
window.mainloop() |
Partager