-
Notifications
You must be signed in to change notification settings - Fork 0
/
animator.py
52 lines (45 loc) · 1.07 KB
/
animator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Animation attempt :((
from msvcrt import getch, putwch, kbhit
from time import sleep
delay = 0.1
string = ""
animation_frames = [
"ooo\nooo\nooo",
"---\nooo\nooo",
"---\n---\nooo",
"---\n---\n---",
"ooo\n---\n---",
"ooo\nooo\n---"
]
current_frame = 0
max_frame = len(animation_frames) - 1
def clear():
print("\n" * 1000)
while True:
clear()
print(animation_frames[current_frame])
print(string)
if kbhit():
key = getch()
# Backspace : b'\x08' Enter: b'\r'
if key == b'\r':
string = ""
elif key == b'\x08':
string = string[0:len(string)-1]
else:
string += key.decode("utf-8")
sleep(delay)
current_frame = current_frame + 1 if not current_frame == max_frame else 0
##while True:
## clear()
## sleep(delay)
## print("INPUT CHARACTERS:")
## print(string)
## keypress = getch()
## if keypress == bin(13):
## print("AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH")
## string = ""
## else:
## x = keypress.decode("utf-8")
## string += x
input()