I'm trying to make a program that makes you lose "energy" for a game.
I made it so when you press enter you gain "energy":
if question == '':
print("press enter to gain energy")
while True:
energyup = input()
if energyup == "":
energy += energygain
print(energy)
I also want to make it so you lose energy every 0.5 seconds. I don't know how to do this.
I tried adding:
while True:
energy -= energyloss
print(energy)
time.sleep(1)
to the bottom of the program, but that makes you lose energy WAY too fast and I don't know if there is a way to make 1 line of code sleep while everything else continues (I'm using time.sleep which affects the whole program) and on top of that it makes the energy gaining system just not work.
Sorry if this is a dumb question I just started learning programing and this is my first question on this site.