Created
November 17, 2015 21:38
-
-
Save HuproZ/ffb691664ed28f118800 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
import time, os | |
from Tkinter import * | |
from math import * | |
import random | |
from tkMessageBox import * | |
import pygame | |
##################################################### booléens pour l'arrêt du chrono | |
c1=True | |
c2=True | |
c3=True | |
pygame.mixer.init() | |
def jeu(): | |
########################################################################### Decomptes +résultats + Defaite | |
def explosion(): | |
explo= Canvas(fen1, width=879, height=660) | |
explo.grid(row=0, column=0) | |
explo.create_image(440, 330, image=photoexplo) | |
btn6=Button(fen1, image=btnrejouer, relief="flat", borderwidth=0, highlightthickness=1, command=recommencer) | |
btn6.place(x=400,y=500) | |
pygame.mixer.music.stop() | |
pygame.mixer.music.load( "explosion.wav" ) | |
pygame.mixer.music.play(0) | |
def decompte(label, count=10): | |
label.config(text="{:.2f}".format(count)) | |
if count > 0 and c1: | |
fen1.after(10,decompte, *(label, count-0.01)) | |
if count<0.15: | |
msg1.configure(text="Parfait", bg="green") | |
if 0.2<count<0.4: | |
msg1.configure(text="Peut mieux faire", bg="orange") | |
if count>0.4: | |
msg1.configure(text="Mauvais timing",bg="red") | |
if count==0 or count<0: | |
explosion() | |
def decompte2(label, count=10): | |
label.config(text="{:.2f}".format(count)) | |
if count > 0 and c2: | |
fen1.after(10,decompte2, *(label, count-0.01)) | |
if count<0.15: | |
msg2.configure(text="Parfait", bg="green") | |
if 0.2<count<0.4: | |
msg2.configure(text="Peut mieux faire", bg="orange") | |
if count>0.4: | |
msg2.configure(text="Mauvais timing", bg="red") | |
if count==0 or count<0: | |
explosion() | |
def decompte3(label, count=10): | |
label.config(text="{:.2f}".format(count)) | |
if count > 0 and c3: | |
fen1.after(10,decompte3, *(label, count-0.01)) | |
if count<0.15: | |
msg3.configure(text="Parfait", bg="green") | |
if 0.2<count<0.4: | |
msg3.configure(text="Peut mieux faire", bg="orange") | |
if count>0.4: | |
msg3.configure(text="Mauvais timing", bg="red") | |
if count==0 or count<0: | |
explosion() | |
####################################################################### Arrêts | |
def stop(): | |
global c1 | |
c1 = False | |
def stop2(): | |
global c2 | |
c2 = False | |
def stop3(): | |
global c3 | |
c3 = False | |
pygame.mixer.music.stop() | |
pygame.mixer.music.load("desamorce.wav") | |
pygame.mixer.music.play(0) | |
##################################################### fenetre du jeu + seleection des valeurs de départ | |
fen1=Toplevel(bg="black") | |
fen1.geometry("879x660") | |
fen1.title("Ca va péter !") | |
canvas = Canvas(fen1,width=879, height=660) | |
canvas.create_image(0, 0, anchor=NW, image=bombes) | |
canvas.pack() | |
chrono1=Label(fen1, text="") | |
chrono1.place(x=186, y=217) | |
chrono1.configure(width=6, height=1) | |
chrono2=Label(fen1, text="") | |
chrono2.place(x=416, y=216) | |
chrono2.configure(width=6, height=1) | |
chrono3=Label(fen1,text="") | |
chrono3.configure(width=6, height=1) | |
chrono3.place(x=642,y=215) | |
msg1=Label(fen1,text="") | |
msg1.place(x=175,y=250) | |
msg2=Label(fen1,text="") | |
msg2.place(x=405,y=250) | |
msg3=Label(fen1,text="") | |
msg3.place(x=630,y=250) | |
x=(random.uniform(1.5,2)) | |
y=(random.uniform(3,3.5)) | |
z=(random.uniform(4.5,5)) | |
##################################################### lancer le décompte automatiquement au lancement de jeu() | |
decompte(chrono1, x) | |
decompte2(chrono2, y) | |
decompte3(chrono3,z) | |
btn1=Button(fen1, text="stop", image=btnstop, command=stop) | |
btn1.place(x=155,y=290) | |
btn5=Button(fen1, text="Stop", image=btnstop, command=stop2) | |
btn5.place(x=385,y=290) | |
btn6=Button(fen1, text="Stop", image=btnstop, command=stop3) | |
btn6.place(x=610,y=290) | |
##################################################### quitter et recommencer | |
def quitter(): | |
pygame.mixer.music.stop() | |
fen1.destroy() | |
fenetre.destroy() | |
btn3=Button(fen1, image=btnquitter, relief="flat", borderwidth=0, highlightthickness=1,command=quitter) | |
btn3.place(x=485,y=500) | |
def recommencer(): | |
global c1 | |
global c2 | |
global c3 | |
c1= True | |
c2=True | |
c3=True | |
fen1.destroy() | |
jeu() | |
pygame.mixer.music.stop() | |
pygame.mixer.music.load("musique_bombe.wav") | |
pygame.mixer.music.play(-1) | |
btn4=Button(fen1, image=btnrejouer,relief="flat", borderwidth=0, highlightthickness=1, command=recommencer) | |
btn4.place(x=280,y=500) | |
###################################################### INTRODUCTION (4 sous parties en dessous) | |
fenetre= Tk() | |
fenetre.geometry("1024x620") | |
fenetre.title("Prépare toi !") | |
####################### Chargement des photos | |
accueil = PhotoImage(file="demineur.gif") | |
bombes = PhotoImage(file="lesbombes.gif") | |
btnstop = PhotoImage(file="stop.gif") | |
photoexplo = PhotoImage(file="explosion.gif") | |
btnrejouer= PhotoImage(file="bouton_rejouer.gif") | |
btnquitter= PhotoImage(file="quitter.gif") | |
canvas= Canvas(fenetre, width=1024, height=620,bg="black") | |
canvas.grid(row=0, column=0) | |
canvas.create_image(512,310, image=accueil) | |
###################### Askyesno | |
def demande(): | |
askyesno("Prêt(e)?","Êtes-vous prêt(e) ?",parent=fenetre,type='ok') | |
pygame.mixer.music.stop() | |
jeu() | |
pygame.mixer.music.load("musique_bombe.wav") | |
pygame.mixer.music.play(-1) | |
#####################Lancer la partie | |
btnjouer=PhotoImage(file="jouer.gif") | |
btn= Button(fenetre, image=btnjouer, relief="flat", borderwidth=0, highlightthickness=1, command=demande) | |
btn.place(x=100,y=460) | |
pygame.mixer.music.load("musique_menu.wav") | |
pygame.mixer.music.play(-1) | |
fenetre.mainloop() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment