-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloading.py
48 lines (39 loc) · 1.39 KB
/
loading.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
import time
class LoadingScreen:
red = [100,0,0]
blue = [0,100,0]
green = [0,0,100]
def __init__(self, hat):
self.hat = hat
self.head = (1,1)
self.body = [(2,1), (3,1), (4,1)]
def show(self):
self.hat.clear()
self.hat.set_pixel(self.head[0], self.head[1], self.red)
for coord in self.body:
self.hat.set_pixel(coord[0], coord[1], self.red)
def update(self):
self.body[-1] = self.body[-2]
self.body[-2] = self.body[-3]
self.body[-3] = self.head
if self.head == (1,1):
self.head = (1,2)
elif self.head == (1,6):
self.head = (2,6)
elif self.head == (6,6):
self.head = (6,5)
elif self.head == (6,1):
self.head = (5,1)
elif (self.head[0] == 1) and (self.head[1] < 6):
self.head = (self.head[0], self.head[1]+1)
elif (self.head[1] == 6) and (self.head[0] < 6):
self.head = (self.head[0]+1, self.head[1])
elif (self.head[0] == 6) and (self.head[1] > 1):
self.head = (self.head[0], self.head[1]-1)
elif (self.head[1] == 1) and (self.head[0] > 1):
self.head = (self.head[0]-1, self.head[1])
def run(self, notReady):
while notReady.isSet():
self.show()
self.update()
time.sleep(0.1)