-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_typing_game.py
57 lines (51 loc) · 2.06 KB
/
main_typing_game.py
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 speed_typing_game import *
from typing_class import *
#author: Love Kildetoft
def mainloop():
"""
main function comprising the whole typing game. uses the class TypingGame created by yours
truly. offers a simple menu screen and initializes the different game types depending on the
user input.
"""
maingame = TypingGame() #initialize typinggame object.
highscore = Scoreboard() #initialize scoreboard object
typing = Typing() #initialize typing object
typing.cls()
menuscreen = True #set up boolean for handling user choice.
while menuscreen: #set up main loop for menu screen.
print("Welcome!")
print("What would you like to do today?")
print("1. Practice typing a number of shorter sentences")
print("2. Practice typing a larger paragraph")
print("3. Clear highscore")
print("4. Exit the game")
highscore.display_score()
try_input = True #set up boolean for handling incorrect menu choices
while try_input: #loop which handles incorrect menu choices
user_input = input()
if user_input == "1":
try_input = False
maingame.sentence_game()
elif user_input == "2":
try_input = False
maingame.paragraph_game()
elif user_input == "3":
highscore.clear_highscore()
try_input = False
elif user_input == "4":
print("Bye!")
try_input = False
menuscreen = False
elif user_input == "42":
for i in range(10):
print("THE ANSWER TO LIFE, THE UNIVERSE AND EVERYTHING")
time.sleep(0.5)
print("The programmer put this in for YOU")
time.sleep(5)
print("Also your highscore is now gone")
highscore.clear_highscore()
try_input = False
else:
print("You can only input 1, 2, 3 or 4")
if __name__ == "__main__":
mainloop()