forked from NM-TAFE/civ-ipriot-smiley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angry.py
49 lines (40 loc) · 1.33 KB
/
angry.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
import time
from blinkable import Blinkable
from smiley import Smiley
class Angry(Smiley, Blinkable):
def __init__(self):
super().__init__(complexion=self.RED)
self.draw_mouth()
self.draw_brows()
self.draw_eyes()
def draw_brows(self):
brows = [10, 13, 19, 20]
for pixel in brows:
self.pixels[pixel] = self.BLANK
def draw_mouth(self):
"""
Method that draws the mouth on the standard faceless smiley.
"""
mouth = [49, 54, 42, 43, 44, 45]
for pixel in mouth:
self.pixels[pixel] = self.BLANK
def draw_eyes(self, wide_open=True):
"""
Method that draws the eyes (open or closed) on the standard smiley.
:param wide_open: True if eyes opened, False otherwise
"""
eyes = [26, 29]
for pixel in eyes:
self.pixels[pixel] = self.BLANK if wide_open else self.complexion()
def blink(self, delay=0.25):
"""
Make the sad smiley blink once with a certain delay (in s).
This is the implementation of the abstract method from the
Blinkable abstract class.
:param delay: Delay in seconds
"""
self.draw_eyes(wide_open=False)
self.show()
time.sleep(delay)
self.draw_eyes(wide_open=True)
self.show()