Den man in 2 Sekunden drücken muss ansonsten soll
Code: Alles auswählen
def reset():
print("du warst nicht schnell genug")
Mein Code bis jetzt (der Button der in der bestimmten Zeit gedrückt werden soll heißt hitButton):
Code: Alles auswählen
from tkinter import *
import random
xr = 40
yr = 40
global hitButton
def restartGame():
root.destroy()
Main()
def noCommand():
print("no command executed")
def failEvent():
global hitButton
print("failed")
OverLabel = Label(image=GameOverIMG)
OverLabel.place(x=200, y=80)
print("test")
hitButton.place(x=232323, y=232323)
bRestart = Button(root, text="Restart", fg="WHITE", bg="BLACK", command=restartGame, width=5, height=3)
bRestart.place(x=200, y=700)
def ButtonHitEvent():
global xr
global yr
xr = random.randint(40, 950)
yr = random.randint(40, 750)
hitButton.place(x=xr, y=yr)
def Main():
global hitButton
global ButtonImg
global ClearIMG
global clearLabelGameOver
global ButtonWindow
global hitButton
global GameOverIMG
global root
root = Tk()
root.geometry("1000x800")
ButtonImg = PhotoImage(file="C:/Users/jakob/AppData/Local/Programs/Python/Python39/Scripts/Scripts/Python/Tkinter/graphics/ButtonClick.png")
GameOverIMG = PhotoImage(file="C:/Users/jakob/AppData/Local/Programs/Python/Python39/Scripts/Scripts/Python/Tkinter/graphics/GameOver.png")
ClearIMG = PhotoImage(file="C:/Users/jakob/AppData/Local/Programs/Python/Python39/Scripts/Scripts/Python/Tkinter/graphics/clear.png")
clearLabelGameOver = Label(root, image=ClearIMG)
clearLabelGameOver.place(x=300, y=200)
ButtonWindow = Button(root, text=" ", width=300, height=300, command=failEvent, background="BLACK", foreground="BLACK").pack()
hitButton = Button(root, image=ButtonImg, command=ButtonHitEvent, fg="BLACK", bg="BLACK")
hitButton.place(x=40, y=40)
root.mainloop()
if __name__ == '__main__':
Main()