Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Color_Game/highest_score.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
11
1 change: 1 addition & 0 deletions Color_Game/highest_score1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
35 changes: 28 additions & 7 deletions Color_Game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def next_colour():
label.config(fg=colours[1], text=colours[0])
score_label.config(text=f"Score: {score}")


def countdown():
global timeleft
if timeleft > 0:
Expand All @@ -38,6 +37,11 @@ def record_highest_score():
if score > highest_score:
with open("highest_score.txt", "w") as file:
file.write(str(score))
elif score <= highest_score:
with open("highest_score1.txt", "w") as file:
file.write(str(score))





Expand All @@ -49,20 +53,36 @@ def load_highest_score():
return int(data)
else:
return 0

except FileNotFoundError:
return 0

def load_your_score():
try:
with open("highest_score1.txt", "r") as file:
data = file.read()
if data:
return int(data)
else:
return 0
except FileNotFoundError:
return 0



def scoreshow():
record_highest_score()
window2 = tk.Tk()
window2 = tk.Toplevel()
window2.title("HIGH SCORE")
window2.geometry("300x200")

label = tk.Label(window2, text=f"Highest Score: {load_highest_score()}",font=(font, 12))
highest_label = tk.Label(window2, text=f"Highest Score: {load_highest_score()}",font=(font, 12))

label.pack()
your_label = tk.Label(window2, text=f"Your Score:{load_your_score()}", font=(font, 12))

highest_label.pack()
your_label.pack()

window2.mainloop()

def start_game(event):
Expand All @@ -74,8 +94,8 @@ def start_game(event):
window = tk.Tk()
font = 'Helvetica'
window.title("Color Game")
window.iconbitmap("color_game_icon.ico")
window.geometry("375x250")
# window.iconbitmap("color_game_icon.ico")
window.geometry("375x350")
window.resizable(False, False)

instructions = tk.Label(window, text="Enter the color of the text, not the word!", font=(font, 12))
Expand All @@ -96,4 +116,5 @@ def start_game(event):

e.focus_set()

window.mainloop()
window.mainloop()

Empty file.
Binary file not shown.