My programs supposed to play a game. It's the loading screen I'm having problems with. When I run it, time.sleep
acts as if it's sleeping 0.1
seconds, instead of the much smaller numbers I input into it. Why is this? Is there a way I can make the delays shorter? Here's the code:
import os
import random
import time
import sys
def mywrite(line2,line1,t,s,x='small'):
if x=='small':
x=0.0000000000000000000000000000000000000000000000000000000000000000000000001
else:
x=random.random()*t+s
word=''
for c in line1:
if line1.index(c)<len(line1)-1:
print(line2)
word=word+c
print(word)
time.sleep(x)
os.system('cls')
else:
print(line2)
word=word+c
print(word,' \n')
time.sleep(x)
mywrite('__________________________________________________________\n',' %33s'%'Scrambled',0.005,0.1,'random')
print(' Press "a" to play %30s'%'Press "s" to exit')
print('__________________________________________________________')
start=input()
if start=='a':
permission=1
if start=='s':
permission=0
if permission==0:
sys.exit()
if permission==1:
print("Choose Difficulty")
print('Easy -Press a')
print('Hard -Press b')
print('Insane -Press c')
diff=input()
y=0
while permission==1:
os.system('cls')
mywrite('''
_ _ _
(_) ___ __ _ __| | | | _ __ __ _
| | / _ \\ / _` | / _` | | | | '_ \\ / _` |
| | | (_) | | (_| | | (_| | | | | | | | | (_| |
|_| \\___/ \\__, | \\__,_| |_| |_| |_| \\__,_|
|___/
''', 0.005, 0.001)
time.sleep(2)
os.system('cls')
mywrite('''
_ _
(_) __ _ | | __ _
| | / _` | | | / _` |
| | | (_| | | | | (_| |
|_| \__, | |_| \__,_|
|___/
_
___ __| | _ __
/ _ \ / _` | | '_ \
| (_) | | (_| | | | | |
\___/ \__,_| |_| |_|
''', 0.005, 0.001)
time.sleep(2)
os.system('cls')
mywrite('''
_ _
| | __ _ (_) __ _
| | / _` | | | / _` |
| | | (_| | | | | (_| |
|_| \__,_| |_| \__, |
|___/
_
___ __| | _ __
/ _ \ / _` | | '_ \
| (_) | | (_| | | | | |
\___/ \__,_| |_| |_|
''', 0.005, 0.001)
time.sleep(2)
os.system('cls')
mywrite('''
_ _ _
| | ___ __ _ __| | (_) _ __ __ _
| | / _ \ / _` | / _` | | | | '_ \ / _` |
| | | (_) | | (_| | | (_| | | | | | | | | (_| |
|_| \___/ \__,_| \__,_| |_| |_| |_| \__, |
|___/
''', 0.005, 0.001)
time.sleep(4)
os.system('cls')
if y==2:
break
If that's too long, here's the part that contains the problem:
import os
import random
import time
import sys
def mywrite(line2,line1,t,s,x='small'):
if x=='small':
x=0.0000000000000000000000000000000000000000000000000000000000000000000000001
else:
x=random.random()*t+s
word=''
for c in line1:
if line1.index(c)<len(line1)-1:
print(line2)
word=word+c
print(word)
time.sleep(x)
os.system('cls')
else:
print(line2)
word=word+c
print(word,' \n')
time.sleep(x)
while permission==1:
os.system('cls')
mywrite('''
_ _ _
(_) ___ __ _ __| | | | _ __ __ _
| | / _ \\ / _` | / _` | | | | '_ \\ / _` |
| | | (_) | | (_| | | (_| | | | | | | | | (_| |
|_| \\___/ \\__, | \\__,_| |_| |_| |_| \\__,_|
|___/
''', 0.005, 0.001)
time.sleep(2)
os.system('cls')
mywrite('''
_ _
(_) __ _ | | __ _
| | / _` | | | / _` |
| | | (_| | | | | (_| |
|_| \__, | |_| \__,_|
|___/
_
___ __| | _ __
/ _ \ / _` | | '_ \
| (_) | | (_| | | | | |
\___/ \__,_| |_| |_|
''', 0.005, 0.001)
time.sleep(2)
os.system('cls')
mywrite('''
_ _
| | __ _ (_) __ _
| | / _` | | | / _` |
| | | (_| | | | | (_| |
|_| \__,_| |_| \__, |
|___/
_
___ __| | _ __
/ _ \ / _` | | '_ \
| (_) | | (_| | | | | |
\___/ \__,_| |_| |_|
''', 0.005, 0.001)
time.sleep(2)
os.system('cls')
mywrite('''
_ _ _
| | ___ __ _ __| | (_) _ __ __ _
| | / _ \ / _` | / _` | | | | '_ \ / _` |
| | | (_) | | (_| | | (_| | | | | | | | | (_| |
|_| \___/ \__,_| \__,_| |_| |_| |_| \__, |
|___/
''', 0.005, 0.001)
time.sleep(4)
os.system('cls')
if y==2:
break
BTW I'm only a few days into python, so please keep the explanations simple. Thank you.