-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathziggy.py
More file actions
44 lines (32 loc) · 1.13 KB
/
Copy pathziggy.py
File metadata and controls
44 lines (32 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
35
36
37
38
39
40
41
42
43
44
from base import LightBase
import colors
class Ziggy(LightBase):
def __init__(self) -> None:
self.indexes = {}
self.directions = {}
@property
def name(self):
return "Ziggy"
@property
def tick_interval(self):
return 0.0000
def tick(self, pixels, max):
pixels.fill((0, 0, 0))
for x in range(0,10):
pixels[self.get_index(x, max)] = colors.BLUE
for x in range(10,20):
pixels[self.get_index(x, max)] = colors.GREEN
def get_index(self, inital_offset, max):
index = self.indexes.get(inital_offset, inital_offset)
direction = self.directions.get(inital_offset, True)
if index + 1 == max:
self.directions[inital_offset] = False
direction = False
if not direction and index == 0:
self.directions[inital_offset] = True
direction = True
if direction:
self.indexes[inital_offset] = index + 1
if not direction:
self.indexes[inital_offset] = index - 1
return index