just use indices in self.boxes instead of the coords
This commit is contained in:
parent
61d86a36d3
commit
1c6ac6e811
1 changed files with 7 additions and 8 deletions
15
__init__.py
15
__init__.py
|
@ -122,13 +122,12 @@ class Quox(Application):
|
|||
|
||||
def add_boxes(self, state):
|
||||
for i, button in enumerate(state.captouch.petals):
|
||||
box = Quox.BOX_COORDS[i]
|
||||
if button.pressed:
|
||||
if box not in self.boxes:
|
||||
self.boxes.append(box)
|
||||
if i not in self.boxes:
|
||||
self.boxes.append(i)
|
||||
else:
|
||||
if box in self.boxes:
|
||||
self.boxes.remove(box)
|
||||
if i in self.boxes:
|
||||
self.boxes.remove(i)
|
||||
|
||||
def update_delay(self, Δ):
|
||||
self.turn_delay -= Δ
|
||||
|
@ -191,7 +190,7 @@ class Quox(Application):
|
|||
|
||||
def target(self):
|
||||
if self.boxes:
|
||||
return self.boxes[0]
|
||||
return Quox.BOX_COORDS[self.boxes[0]]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -214,8 +213,8 @@ class Quox(Application):
|
|||
|
||||
def update_leds(self):
|
||||
leds.set_all_rgb(0, 0, 0)
|
||||
for i, box in enumerate(Quox.BOX_COORDS):
|
||||
if box in self.boxes:
|
||||
for i in range(10):
|
||||
if i in self.boxes:
|
||||
center = i * 4
|
||||
left = (center - 1) % 40
|
||||
right = (center + 1) % 40
|
||||
|
|
Loading…
Reference in a new issue