import threading
import time
# Initialize the score
score = 0
running = True
sps = 1
def increment_score():
"""Automatically add 1 to the score every second."""
global score, running
while running:
time.sleep(1)
score += sps
print(f"Score (auto): {score}")
def sps_upgrade_1():
while running:
if score > 25:
while running:
res = input("Would you like to spend 25 points to get +1 point a sec? (Y/N")
if type(res) == str:
if res == "Y":
print("y")
elif res == "N":
print("n")
else:
print("Please type Y or N")
else:
print("Input must be string")
def play_game():
"""Main game loop where the player presses 'f' to increase the score."""
global score, running
print("Press 'f' to increase your score! Press 'q' to quit.")
# Start the auto-increment function in a separate thread
auto_increment_thread = threading.Thread(target=increment_score)
auto_increment_thread.start()
# Main game loop
try:
while running:
if input() == "f": # Detect if the 'f' key is pressed
score += 1
print(f"Score: {score}")
# Prevent multiple rapid presses from counting as one
elif input() == "q": # Quit the game if 'q' is pressed
running = False
print("Game Over!")
except KeyboardInterrupt:
running = False
print("\nGame interrupted. Goodbye!")
# Ensure the thread ends before exiting
auto_increment_thread.join()
if __name__ == "__main__":
play_game()
Hi, I am trying to make a clicker game. The click and sps is sorted but i wanted a way to (test) an upgrade function. i want it to appear when i have 25 score but i tried out different code and it didnt seem to work.