-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_attack.py
More file actions
79 lines (63 loc) · 2.34 KB
/
time_attack.py
File metadata and controls
79 lines (63 loc) · 2.34 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def play_time_attack(name="Player",level=1,timer=30):
import time
import EquationQuest
from tkinter.simpledialog import askinteger
import tkinter as Tk
import tkinter
import tkinter.ttk as ttk
import tkinter.font as font
root = tkinter.Tk()
numbercorrect = tkinter.Tk()
#number correct
numbercorrect.geometry("100x100+1400+1")
#timer
#window
root.geometry("300x105+1+1")
root.title("Time Attack")
instructions = ttk.Label(root, text="Answer as many quesitons as you can in 30 seconds")
instructions.pack()
#scoredisplay
labelscore = Tk.Label(numbercorrect, text = "Score: ")
labelscore.place(x=5, y=5)
score = 0
scoredisplay = Tk.Label(numbercorrect, text = f"{score}")
scoredisplay.place(x=50,y=5)
#timeer
labeltimer =Tk.Label(numbercorrect, text = "Time left: ")
labeltimer.place(x=5,y=50)
timershow = 0
timerdisplay =Tk.Label(numbercorrect, text = f"{timershow}")
timerdisplay.place(x=60, y= 50)
def wait():
score = 0
start = time.time()
timershow = int(abs(time.time() - start - 30))
while(timer > time.time() - start):
timershow = int(abs(time.time() - start - 30))
timerdisplay =Tk.Label(numbercorrect, text = f"{timershow}")
timerdisplay.place(x=60, y= 50)
problem = EquationQuest.generate_problem(1)
num = askinteger("Input", f"Input the Answer to {problem}")
if num == EquationQuest.ans:
#scoredisplay
score += 1
scoredisplay = Tk.Label(numbercorrect, text = f"{score}")
scoredisplay.place(x=50,y=5)
elif num == None:
return 0
#start button
start = Tk.Button(root, text ="GO",fg ='white', bg = 'red', command = wait)
start.place(x=50,y=45)
#back button
backtomenu = tkinter.Tk()
backtomenu.geometry("100x100+1400+680")
def back():
numbercorrect.withdraw()
root.withdraw()
backtomenu.withdraw()
import MainMenu
MainMenu.menu()
backbutton = Tk.Button(backtomenu, text= "Back", command = back)
backbutton.place(x=5,y=5)
root.mainloop()
play_time_attack()