-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathface.py
More file actions
36 lines (31 loc) · 1.13 KB
/
face.py
File metadata and controls
36 lines (31 loc) · 1.13 KB
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
from consts import SETTINGS
SETTINGS["face_animation"].sort()
FRAMES_FOR_ONE_MOVE = SETTINGS["face_animation"][-1][0]
pointer = 0
def face(frame: int, mouse_clicked: bool = False, talking: bool = False):
"""
Return the proper face to display
params:
frame (int): The frame (1~inf)
mouse_clicked (int): Whether the mouse is clicked
talking (bool): Whether the person is talking
"""
global pointer
eye = SETTINGS["face_click_eye"] if mouse_clicked else SETTINGS["face_normal_eye"]
mouth = SETTINGS["face_talking_mouth"] if talking else SETTINGS["face_normal_mouth"]
if SETTINGS["face_animation"][pointer][0]<frame:
pointer += 1
res = __replacer(SETTINGS["face_animation"][pointer][1], eye, mouth)
if frame == FRAMES_FOR_ONE_MOVE:
pointer = 0
return res
def __replacer(face_string: str, eye: str, mouth: str) -> str:
s = ""
for c in face_string:
if c == SETTINGS["replace_char_as_eye"]:
s += eye
elif c == SETTINGS["replace_char_as_mouth"]:
s += mouth
else:
s += c
return s.center(SETTINGS["text_len"])