from Tkinter import * from Tkinter import * import time as t #******************************************************************************# #* *# #* * * * VARIABLES INITIALES * * * *# #* *# #******************************************************************************# # position initiale des champions PosX = 0 PosY = 0 PosX1 = 950 PosY1 = 550 #Variables generales actuTour=0 move=3 #deplacement des joueurs Dep1 = 15 Dep2 = 15 #******************************************************************************# #* *# #* * * * FONCTIONS UTILISEES * * * *# #* *# #******************************************************************************# def Quitter(event): Jeu.destroy() def Clic(event): global PosX,PosY """ Gestion de l'?v?nement Clic gauche sur la zone graphique """ # position du pointeur de la souris ClikX = event.x ClikY = event.y print("et tu clique") print(ClikX,ClikY) if (ClikX>PosX and ClikXPosY and ClikYPosX1 and ClikXPosY1 and ClikY 0 : # d?placement vers le haut if touche == 'Up': PosY -= 50 move=move-1 if (PosX==PosX1 and PosY==PosY1) or PosY<0 or PosY>575 : PosY += 50 move=move+1 else : print() # d?placement vers le bas if touche == 'Down': PosY += 50 move=move-1 if (PosX==PosX1 and PosY==PosY1) or PosY<0 or PosY>575 : PosY -= 50 move=move+1 else : print() # d?placement vers la droite if touche == 'Right': PosX += 50 move=move-1 if (PosX==PosX1 and PosY==PosY1) or PosX<0 or PosX>975 : PosX -= 50 move=move+1 else : print() # d?placement vers la gauche if touche == 'Left': PosX -= 50 move=move-1 if (PosX==PosX1 and PosY==PosY1) or PosX<0 or PosX>975 : PosX += 50 move=move+1 else : print() # on dessine le pion ? sa nouvelle position ActuIm() else : print() elif actuTour == 1 : if move >0 : # d?placement vers le haut if touche == 'Up': PosY1 -= 50 move=move-1 if (PosX1==PosX and PosY1==PosY) or PosY1<0 or PosY1>575 : PosY1 += 50 move=move+1 else : print() # d?placement vers le bas if touche == 'Down': PosY1 += 50 move=move-1 if (PosX1==PosX and PosY1==PosY) or PosY1<0 or PosY1>575 : PosY1 -= 50 move=move+1 else : print() # d?placement vers la droite if touche == 'Right': PosX1 += 50 move=move-1 if (PosX1==PosX and PosY1==PosY) or PosX1<0 or PosX1>975 : PosX1 -= 50 move=move+1 else : print() # d?placement vers la gauche if touche == 'Left': PosX1 -= 50 move=move-1 if (PosX1==PosX and PosY1==PosY) or PosX1<0 or PosX1>975 : PosX1 += 50 move=move+1 else : print() # on dessine le pion ? sa nouvelle position ActuIm() else : print() def decompte(count=3): global actuTour if count >= 0 : Jeu.after(1000,decompte, count-1) else : actuTour=actuTour+1 if actuTour > 1 : actuTour=0 Tour() decompte() def Tour(): global move,Dep1,Dep2,actuTour if actuTour==0 : move = Dep1 elif actuTour==1 : move = Dep2 #******************************************************************************# #* *# #* * * * PROGRAMME PRINCIPAL * * * *# #* *# #******************************************************************************# # Creation de la fenetre windows Jeu=Tk() Jeu.title("CheckMate") Jeu.iconbitmap("checkmate.ico") Jeu.geometry("1200x700") Jeu.resizable(width=False,height=False) Jeu.configure() # Creation des frames principales frame3 = Frame(Jeu, bg="yellow", width=200, height=720) frame3.pack(side=LEFT) frame1 = Frame(Jeu, bg="black", width=1000, height=600) frame1.pack(side=BOTTOM) Canevas = Canvas(frame1, width = 1000, height =600, bg ='white') fond = PhotoImage(file="TRY.gif") Canevas.create_image(0, 0, anchor=NW, image=fond) Image1 = PhotoImage(file="Tete_Archer.gif") Image2 = PhotoImage(file="Tete_Mage.gif") Canevas.create_image(PosX+25, PosY+25, anchor=CENTER, image=Image1) Canevas.create_image(PosX1+25, PosY1+25, anchor=CENTER, image=Image2) for i in range(0,1000,50): Canevas.create_line(i,0,i,620,fill="#000000") for j in range(0,620,50): Canevas.create_line(0,j,1000,j,fill="#000000") Canevas.focus_set() Canevas.bind('', Clic) Canevas.bind('',Clavier) Canevas.pack() frame2 = Frame(Jeu, bg="blue", width=1000, height=100) frame2.pack() # Creation des frames secondaires # Frames de gauches framea = Frame(frame3, bg="yellow",width=200, height=70) framea.pack (side=TOP) photoa = PhotoImage(file="test1.gif") Canfra = Canvas(framea, width=200, height=70, bg="yellow") item1 = Canfra.create_image(0,0,anchor=NW, image=photoa) Jeu.focus_set() Canfra.bind('', Quitter) Canfra.pack() frameb = Frame(frame3, bg="green",width=200, height=90) frameb.pack (side=TOP) Canfrb = Canvas(frameb, width=200, height=90, bg="green") Jeu.focus_set() Canfrb.bind('', Clicb) Canfrb.pack() framec = Frame(frame3, bg="red",width=200, height=90) framec.pack (side=TOP) Canfrc = Canvas(framec, width=200, height=90, bg="pink") Jeu.focus_set() Canfrc.bind('', Clicc) Canfrc.pack() framed = Frame(frame3, bg="green",width=200, height=320) framed.pack (side=TOP) photod=PhotoImage(file="VIE.gif") Canfrd = Canvas(framed, width=200, height=320) itemd = Canfrd.create_image(0,0,anchor=NW, image=photod) Canfrd.pack() """Barre de vies""" Vie1=100 Vie2=100 echelle1 = Scale(framed,from_=100,to=0,resolution=1,orient=VERTICAL,\ length=300,width=40) echelle1.set(Vie1) echelle1.pack(side=RIGHT) echelle2 = Scale(framed,from_=100,to=0,resolution=1,orient=VERTICAL,\ length=300,width=40) echelle2.set(Vie2) echelle2.pack() framee = Frame(frame3, bg="white",width=200, height=130) framee.pack () Canfre = Canvas(framee, width=200, height=130, bg="green") Jeu.focus_set() Canfre.bind('', Clice) Canfre.pack() # Frames du haut # Frames de la longueur framef = Frame(frame2, bg="yellow",width=90, height=100) framef.pack (side=LEFT) Canfrf = Canvas(framef, width=90, height=100, bg="red") Jeu.focus_set() Canfrf.bind('', Clicf) Canfrf.pack() frameg = Frame(frame2, bg="green",width=90, height=100) frameg.pack (side=LEFT) Canfrg = Canvas(frameg, width=90, height=100, bg="green") Jeu.focus_set() Canfrg.bind('', Clicg) Canfrg.pack() frameh = Frame(frame2, bg="white",width=450, height=100) frameh.pack (side=LEFT) framei = Frame(frame2, bg="green",width=380, height=100) framei.pack () Canfri = Canvas(framei, width=380, height=100, bg="green") Jeu.focus_set() Canfri.bind('', Clici) Canfri.pack() # Frames des sorts/tour framej = Frame(frameh, bg="black",width=450, height=65) framej.pack (side=TOP) framek = Frame(frameh, bg="white",width=450, height=35) framek.pack (expand=1) framel = Frame(framej, bg="red",width=90, height=65) framel.pack (side=LEFT) Canfrl = Canvas(framel, width=90, height=65, bg="green") Jeu.focus_set() Canfrl.bind('', Clicl) Canfrl.pack() framem = Frame(framej, bg="black",width=90, height=65) framem.pack (side=LEFT) Canfrm = Canvas(framem, width=90, height=65, bg="green") Jeu.focus_set() Canfrm.bind('', Clicm) Canfrm.pack() framen = Frame(framej, bg="red",width=90, height=65) framen.pack (side=LEFT) Canfrn = Canvas(framen, width=90, height=65, bg="green") Jeu.focus_set() Canfrn.bind('', Clicn) Canfrn.pack() frameo = Frame(framej, bg="black",width=90, height=65) frameo.pack (side=LEFT) Canfro = Canvas(frameo, width=90, height=65, bg="green") Jeu.focus_set() Canfro.bind('', Clico) Canfro.pack() framep = Frame(framej, bg="red",width=90, height=65) framep.pack () Canfrp = Canvas(framep, width=90, height=65, bg="green") Jeu.focus_set() Canfrp.bind('', Clicp) Canfrp.pack() #Variable pour savoir qui valide son choix V=1 #Valeurs nulles car elles vont changer HP=Dep=Dg_B=Dg_S1=Dg_S2=Po_B=Po_S1=Po_S2=0 def Archer_Select(event): print ("Archer") Canfr41.delete(ALL) Canfr41.create_image(0,0,anchor=NW, image=Archer_Stats) Canfr42.delete(ALL) Canfr42.create_image(0,0,anchor=NW, image=Archer) HP=75 Dep=4 Dg_B=20 Dg_S1=50 Dg_S2=10 Po_B=3 Po_S1=1 Po_S2=4 def Mage_Select(event): print("Mage") Canfr41.delete(ALL) Canfr41.create_image(0,0,anchor=NW, image=Mage_Stats) Canfr42.delete(ALL) Canfr42.create_image(0,0,anchor=NW, image=Mage) HP=150 Dep=3 Dg_B=10 Dg_S1=-20 #Soin Dg_S2=25 Po_B=3 Po_S1=0 Po_S2=2 def Chevalier_Select(event): print("Chevalier") Canfr41.delete(ALL) Canfr41.create_image(0,0,anchor=NW, image=Chevalier_Stats) Canfr42.delete(ALL) Canfr42.create_image(0,0,anchor=NW, image=Chevalier) HP=200 Dep=2 Dg_B=30 Dg_S1=40 Dg_S2=10 Po_B=1 Po_S1=1 Po_S2=2 def Validation(event): global V,HP,Dep,Dg_B,Dg_S1,Dg_S2,Po_B,Po_S1,Po_S2 print("Validation") if V==1: V=V+1 Canfr31.delete(ALL) Canfr41.delete(ALL) Canfr42.delete(ALL) Im2 = Canfr1.create_image(0,0,anchor=NW, image=J2_S) Canfr31.create_image(0,0,anchor=NW, image=No_Select_2) Canfr41.create_image(0,0,anchor=NW, image=No_Select_1) Canfr42.create_image(0,0,anchor=NW, image=No_Select) HP_MAX_1=HP Dg_B_1=Dg_B Dg_S1_1=Dg_S1 Dg_S2_1=Dg_S2 Dep_1=Dep Po_B_1=Po_B Po_S1_1=Po_S1 Po_S2_1=Po_S2 elif V==2: print("2") Jeu.mainloop() Fen=Tk() Fen.title("CheckMate") Fen.iconbitmap("CheckMate.ico") Fen.geometry("1220x710") Fen.resizable(width=False,height=False) Fen.configure() Logo=PhotoImage(file="Logo.gif") Valider=PhotoImage(file="Valider.gif") J1_S=PhotoImage(file="J1_Select.gif") # le joueur 1 selectionne J2_S=PhotoImage(file="J2_Select.gif") # le joueur 2 selectionne Mage=PhotoImage(file="Corps_Mage.gif") # mage Archer=PhotoImage(file="Corps_Archer.gif") # archer Chevalier=PhotoImage(file="Corps_Chevalier.gif") # chevalier B_Mage=PhotoImage(file="Bande_Mage.gif") # Bande mage B_Archer=PhotoImage(file="Bande_Archer.gif") # Bande archer B_Chevalier=PhotoImage(file="Bande_Chevalier.gif") # Bande Chevalier Archer_Stats=PhotoImage(file="Archer_Stats.gif") # Stats Archer Mage_Stats=PhotoImage(file="Mage_Stats.gif") # Stats Mage Chevalier_Stats=PhotoImage(file="Chevalier_Stats.gif") # Stats Chevalier No_Select=PhotoImage(file="NO_Select.gif") # Pas de champion-Image No_Select_1=PhotoImage(file="No_Select_1.gif") # Pas de champion-Stats No_Select_2=PhotoImage(file="No_Select_2.gif") # Pas de champion-Sorts #Frame du texte jouer X choisi frame1 = Frame(Fen, bg="green",width=1200, height=50) frame1.pack (side=TOP) Canfr1 = Canvas(frame1, width=1200, height=50) Im1 = Canfr1.create_image(0,0,anchor=NW, image=J1_S) #rajouter le changement de joueur Canfr1.pack() #Frame des bandes (selection) frame2 = Frame(Fen,width=201, height=650) frame2.pack (side=LEFT) frame21 = Frame(frame2, bg="red",width=67, height=650) frame21.pack (side=LEFT) Canfr21 = Canvas(frame21, width=67, height=650) Im21 = Canfr21.create_image(0,0,anchor=NW, image=B_Archer) Fen.focus_set() Canfr21.bind('', Archer_Select) Canfr21.pack() frame22 = Frame(frame2, bg="yellow",width=67, height=650) frame22.pack (side=LEFT) Canfr22 = Canvas(frame22, width=67, height=650) Im22 = Canfr22.create_image(0,0,anchor=NW, image=B_Chevalier) Fen.focus_set() Canfr22.bind('', Chevalier_Select) Canfr22.pack() frame23 = Frame(frame2, bg="red",width=67, height=650) frame23.pack () Canfr23 = Canvas(frame23, width=67, height=650) Im23 = Canfr23.create_image(0,0,anchor=NW, image=B_Mage) Fen.focus_set() Canfr23.bind('', Mage_Select) Canfr23.pack() #Frame du centre frame3 = Frame(Fen,width=799, height=650) frame3.pack(side=LEFT) frame31 = Frame(frame3, bg="blue",width=799, height=475) frame31.pack(side=TOP) Canfr31 = Canvas(frame31, width=799, height=475) Canfr31.create_image(0,0,anchor=NW, image=No_Select_2) Canfr31.pack() frame32 = Frame(frame3,width=799, height=175) frame32.pack() frame321 = Frame(frame32,width=262, height=175) frame321.pack(side=LEFT) Canfr321 = Canvas(frame321, width=262, height=175) Canfr321.create_image(0,0,anchor=NW, image=Logo) Canfr321.pack() frame322 = Frame(frame32,width=262, height=175) frame322.pack(side=RIGHT) Canfr322 = Canvas(frame322, width=262, height=175) Canfr322.create_image(0,0,anchor=NW, image=Logo) Canfr322.pack() frame323 = Frame(frame32,width=275, height=175) frame323.pack() Canfr323 = Canvas(frame323, width=275, height=175) Canfr323.create_image(0,0,anchor=NW, image=Valider) Fen.focus_set() Canfr323.bind('', Validation) Canfr323.pack() #Frame de droite frame4 = Frame(Fen,width=200, height=650) frame4.pack () frame41 = Frame(frame4, bg="red",width=200, height=250) frame41.pack (side=TOP) Canfr41 = Canvas(frame41, width=200, height=250) Canfr41.create_image(0,0,anchor=NW, image=No_Select_1) Canfr41.pack() frame42 = Frame(frame4, bg="grey",width=200, height=400) frame42.pack () Canfr42 = Canvas(frame42, width=200, height=400) Canfr42.create_image(0,0,anchor=NW, image=No_Select) Canfr42.pack() Fen.mainloop()