-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawing.py
30 lines (26 loc) · 914 Bytes
/
drawing.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
from neopixel import *
from enemy import Enemy
class Drawing():
'''
The drawing class.
'''
def __init__(self, leds):
self.leds = leds
self.stripe = Adafruit_NeoPixel(leds, 18, 800000, 5, False, 255)
self.stripe.begin()
self.emptyPlaceColor = [0, 0, 0]
def gamePlan(self, plan):
'''
Draw the game plan. (Send to the stripe)
:param plan: The game plan to draw.
'''
for led in range(self.leds):
if(plan[led] == None):
self.stripe.setPixelColorRGB(led, self.emptyPlaceColor[0], self.emptyPlaceColor[1], self.emptyPlaceColor[2])
else:
if(isinstance(plan[led], Enemy)):
factor = plan[led].hitCount
self.stripe.setPixelColorRGB(led, int(plan[led].color[0] / factor), int(plan[led].color[1] / factor), int(plan[led].color[2] / factor))
else:
self.stripe.setPixelColorRGB(led, plan[led].color[0], plan[led].color[1], plan[led].color[2])
self.stripe.show()