|
|
@ -4,6 +4,7 @@ from time import sleep |
|
|
|
lst_c=[] |
|
|
|
lst_grille=[] |
|
|
|
f_cont=[] |
|
|
|
########Fonction interface utilisateur########### |
|
|
|
def creer_grille(): |
|
|
|
global taille_carré |
|
|
|
global lst_c |
|
|
@ -61,7 +62,8 @@ def change(event): |
|
|
|
elif grille[num_ligne][num_colone]==1: |
|
|
|
grille[num_ligne][num_colone]=0 |
|
|
|
afficheCarte () |
|
|
|
|
|
|
|
|
|
|
|
######Fonction de génération########## |
|
|
|
def gen_suiv(): |
|
|
|
global grille |
|
|
|
global copy_grille |
|
|
@ -98,12 +100,28 @@ def gen_cont(): |
|
|
|
f_cont=True |
|
|
|
while f_cont==True: |
|
|
|
gen_suiv() |
|
|
|
|
|
|
|
sleep(0.1) |
|
|
|
if f_cont==False: |
|
|
|
break |
|
|
|
def stop(): |
|
|
|
global f_cont |
|
|
|
f_cont=False |
|
|
|
#########Fonction système sauvegarde######## |
|
|
|
def save(): |
|
|
|
state=open("grille_jeu.txt","w") |
|
|
|
state.write("[[") |
|
|
|
for ligne in range (0,len(grille)): |
|
|
|
if ligne!=0 or ligne==len(grille)-1: |
|
|
|
state.write("],[") |
|
|
|
for col in range (0,len(grille[0])): |
|
|
|
if col == len(grille[0])-1: |
|
|
|
state.write(str(grille[ligne][col])) |
|
|
|
else: |
|
|
|
state.write(str(grille[ligne][col])+",") |
|
|
|
state.write("]]") |
|
|
|
|
|
|
|
def load(): |
|
|
|
new_state=open(tk.filedialog.askopenfilename(initialdir = "/",title = "Choisir un fichier",filetypes = (("Text files","*.txt*"),)),"r") |
|
|
|
##########Programme principale############## |
|
|
|
fenetre = tk.Tk() |
|
|
|
fenetre.title("Jeu Amoa") |
|
|
@ -137,7 +155,10 @@ gen_continue.grid(row=8,column=1) |
|
|
|
|
|
|
|
stop=tk.Button(text="Stop",command=stop) |
|
|
|
stop.grid(row=9,column=1) |
|
|
|
############################################ |
|
|
|
|
|
|
|
################Système sauvegarde########## |
|
|
|
save=tk.Button(text="Sauvegarder",command=save) |
|
|
|
save.grid(row=4,column=3) |
|
|
|
load=tk.Button(text="Charger",command=load) |
|
|
|
load.grid(row=5,column=3) |
|
|
|
zone.bind_all('<Button-3>', change) |
|
|
|
fenetre.mainloop() |