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
| from tkinter import *
Window = Tk()
Window.title("Cookie Clicker")
Window.wm_iconbitmap("cookie.ico")
Window.geometry("1080x720")
Window.minsize(1080, 720)
Window.maxsize(1080, 720)
Window.config(background="#F7B95F")
cookie = 0
cookie_upgrade = FALSE
#Logique du Bouton
def button_click():
global cookie
if cookie_upgrade_status == FALSE:
cookie += 1
Compteur_1.config(text=cookie)
elif cookie_upgrade_status == True :
cookie += 10
Compteur_1.config(text=cookie)
#Logique du bouton "upgrade"
def button_upgrade():
if cookie > 25 :
cookie =-25
cookie_upgrade_status = True
#Frame Principale :
Frame_Principal = Frame(Window,background="#F7B95F")
Frame_Principal.pack(side=BOTTOM, pady=90)
#Titre :
Label_title = Label(Window, text="Cookie Clicker", font=("Cooper Black", 40),background="#F7B95F",foreground="#4A2E05")
Label_title.pack()
#Compteur
Compteur_1 = Label(Frame_Principal, text="0")
Compteur_1.pack(fill=X)
#Cookie image :
Widht = 320
Height = 309
Picture_Cookie = PhotoImage(file="cookie.png").zoom(1).subsample(1)
canvas_1 = Canvas(Frame_Principal, width=Widht, height=Height, background="#F7B95F", bd=0, highlightthickness=0)
canvas_1.create_image(Widht/2, Height/2, image=Picture_Cookie)
canvas_1.pack(expand=True,pady=55)
#Bouton
Cookie_button = Button(Frame_Principal, text="Click for 1 Cookie", font=("Arial", 15), foreground="#4A2E05",bg="#CE8418", command=button_click)
Cookie_button.pack(fill="both", pady=10)
#Bouton_upgrade
cookie_upgrade=Button(Frame_Principal, text="25 Cookies For 1 Click = 5 Cookies", font=("Arial", 15), foreground="#4A2E05",bg="#CE8418",command=button_upgrade)
cookie_upgrade.pack(fill="both")
Window.mainloop() |
Partager