How do I code my game in python to pause without losing time from my clock?

36 Views Asked by At

I've tried to save where the clock is at in a .txt file and then reset it to the time in the .txt file but it keeps on going and doesn't reset to what is in the .txt file.

This is the code for how I've been trying to pause it

from time import*

with open('prevend.txt', mode='w', encoding='utf-8') as prv:
    prv.write(str(120))
with open('prevend.txt', mode='r', encoding='utf-8') as prv:
    prevend=int(prv.read())
def pause(end):
    Game = 'pause'
    if Game=='pause':
        with open('prevend.txt', mode='w', encoding='utf-8') as prv:
            prevend=int(prv.write(str(end)))
        play=input("To start again type 'start': ")
        if play=='start':
            Game=='play'
            with open('prevend.txt', mode='r', encoding='utf-8') as prv:
                prevend=float(prv.read())-time()
end=time()+prevend
while end>time():
    end=end-1
    new = input('Enter "pause" to pause game:')
    new = new.lower()
    if new=='pause':
        pause(end)
0

There are 0 best solutions below