-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface.py
52 lines (46 loc) · 1.91 KB
/
face.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
import pygame
import random
import sys
import os
import expressions
def translation_expression(expression):
print(expression)
if expression == "be regular":
return expressions.REGULAR
if expression in ["be sad", "goodnight", "goodbye"]:
return expressions.SAD
if expression in ["be happy", "hi", "hello steve", "hi monkey"]:
return expressions.HAPPY
if expression in ["do you smell it", "are you even working?"]:
return expressions.SUSPICIOUS
if expression in ["bang bang"]:
return expressions.DEAD
if expression == "oh my god":
return expressions.SHOCKED
if expression == "music":
return expressions.MUSIC
return expressions.QUESTION
def start_face(expressions_queue):
pygame.mouse.set_cursor((8, 8), (0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0))
screen = pygame.display.set_mode((480, 320),
pygame.RESIZABLE if os.getenv("FACE_SIZE") == "WINDOW" else pygame.FULLSCREEN)
allExpressions = [expressions.REGULAR, expressions.QUESTION, expressions.SHOCKED, expressions.SUSPICIOUS,
expressions.HAPPY, expressions.SAD]
current = expressions.REGULAR
while True:
for e in pygame.event.get():
if e.type == pygame.KEYDOWN:
if e.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
current = random.choice(allExpressions)
if e.type == pygame.MOUSEMOTION:
current = expressions.SHOCKED
if e.type == pygame.KEYUP or e.type == pygame.MOUSEBUTTONUP:
current = expressions.REGULAR
if expressions_queue.empty() is False:
current = translation_expression(expressions_queue.get())
timer = pygame.time.Clock()
timer.tick()
screen.blit(current.image, current.rect)
pygame.display.update()