Created
November 14, 2015 00:05
-
-
Save HuproZ/c3f002fbe51d9edeeab1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: cp1252 -*- | |
import time, os | |
from Tkinter import * | |
from math import * | |
import random | |
from tkMessageBox import * | |
##################################################### | |
countdown=True | |
c2=True | |
c3=True | |
def new(): | |
########################################################################### Decomptes+résultats | |
def decompte(lab, count=10): | |
lab.config(text="{:.2f}".format(count)) | |
if count > 0 and countdown: | |
fen1.after(10,decompte, *(lab, count-0.01)) | |
if count<0.2: | |
lab4.configure(text="Bien !", bg="green") | |
if 0.2<count<0.4: | |
lab4.configure(text="Pas mal !", bg="orange") | |
if count>0.4: | |
lab4.configure(text="A chier !", bg="red") | |
if count==0 or count<0: | |
lab4.configure(text="Perdu !", bg="red") | |
def decompte2(lab1, count=10): | |
lab1.config(text="{:.2f}".format(count)) | |
if count > 0 and c2: | |
fen1.after(10,decompte2, *(lab1, count-0.01)) | |
if count<0.2: | |
lab5.configure(text="Bien !", bg="green") | |
if 0.2<count<0.4: | |
lab5.configure(text="Pas mal !", bg="orange") | |
if count>0.4: | |
lab5.configure(text="A chier !", bg="red") | |
if count==0 or count<0: | |
lab5.configure(text="Perdu !", bg="red") | |
def decompte3(lab2, count=10): | |
lab2.config(text="{:.2f}".format(count)) | |
if count > 0 and c3: | |
fen1.after(10,decompte3, *(lab2, count-0.01)) | |
if count<0.2: | |
lab6.configure(text="Bien !", bg="green") | |
if 0.2<count<0.4: | |
lab6.configure(text="Pas mal !", bg="orange") | |
if count>0.4: | |
lab6.configure(text="A chier !", bg="red") | |
if count==0 or count<0: | |
lab6.configure(text="Perdu !", bg="red") | |
####################################################################### Arrêts + Jeu en lui même + sélection au hasard des valeurs de départ pour les bombes | |
def stop(): | |
global countdown | |
countdown = False | |
def stop2(): | |
global c2 | |
c2 = False | |
def stop3(): | |
global c3 | |
c3 = False | |
fen1=Tk() | |
fen1.geometry("500x500") | |
lab=Label(fen1, text="") | |
lab1=Label(fen1, text="") | |
lab2=Label(fen1, text="") | |
lab3=Label(fen1,text="") | |
lab3.place(x=300,y=200) | |
lab4=Label(fen1,text="") | |
lab4.place(x=100,y=250) | |
lab5=Label(fen1,text="") | |
lab5.place(x=200,y=250) | |
lab6=Label(fen1,text="") | |
lab6.place(x=300,y=250) | |
x=(random.uniform(1.5,2)) | |
y=(random.uniform(3,3.5)) | |
z=(random.uniform(4.5,5)) | |
decompte(lab, x) | |
decompte2(lab2, y) | |
decompte3(lab3,z) | |
btn1=Button(fen1, text="stop", command=stop) | |
btn1.place(x=100,y=225) | |
btn5=Button(fen1, text="Stop", command=stop2) | |
btn5.place(x=200,y=225) | |
btn6=Button(fen1, text="Stop2", command=stop3) | |
btn6.place(x=300,y=225) | |
btn3=Button(fen1, text="quit",command=fen1.destroy) | |
btn3.place(x=375,y=350) | |
lab.place(x=100,y=200) | |
lab1.place(x=150,y=200) | |
lab2.place(x=200,y=200) | |
##################################################### Recommencement | |
def recommencer(): | |
global countdown | |
global c2 | |
global c3 | |
countdown= True | |
c2=True | |
c3=True | |
fen1.destroy() | |
new() | |
btn4=Button(fen1, text="rejouer", command=recommencer) | |
btn4.place(x=300,y=350) | |
###################################################### Introduction | |
fenetre= Tk() | |
fenetre.configure(bg="black") | |
fenetre.geometry("1024x620") | |
canvas= Canvas(fenetre, width=1024, height=620,bg="black") | |
canvas.grid(row=0, column=0) | |
photo = PhotoImage(file="demineur.gif") | |
canvas.create_image(512,310, image=photo) | |
############################################################## Ready ?! GO ! | |
def demande(): | |
askyesno("Prêt(e)?","Êtes-vous prêt(e) ?",parent=fenetre,type='ok') | |
new() | |
############################################################## | |
btn= Button(fenetre, text="JOUER",bg="yellow",command=demande) | |
btn.place(x=240,y=500) | |
fenetre.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment