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):
|
def add_boxes(self, state):
|
||||||
for i, button in enumerate(state.captouch.petals):
|
for i, button in enumerate(state.captouch.petals):
|
||||||
box = Quox.BOX_COORDS[i]
|
|
||||||
if button.pressed:
|
if button.pressed:
|
||||||
if box not in self.boxes:
|
if i not in self.boxes:
|
||||||
self.boxes.append(box)
|
self.boxes.append(i)
|
||||||
else:
|
else:
|
||||||
if box in self.boxes:
|
if i in self.boxes:
|
||||||
self.boxes.remove(box)
|
self.boxes.remove(i)
|
||||||
|
|
||||||
def update_delay(self, Δ):
|
def update_delay(self, Δ):
|
||||||
self.turn_delay -= Δ
|
self.turn_delay -= Δ
|
||||||
|
@ -191,7 +190,7 @@ class Quox(Application):
|
||||||
|
|
||||||
def target(self):
|
def target(self):
|
||||||
if self.boxes:
|
if self.boxes:
|
||||||
return self.boxes[0]
|
return Quox.BOX_COORDS[self.boxes[0]]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -214,8 +213,8 @@ class Quox(Application):
|
||||||
|
|
||||||
def update_leds(self):
|
def update_leds(self):
|
||||||
leds.set_all_rgb(0, 0, 0)
|
leds.set_all_rgb(0, 0, 0)
|
||||||
for i, box in enumerate(Quox.BOX_COORDS):
|
for i in range(10):
|
||||||
if box in self.boxes:
|
if i in self.boxes:
|
||||||
center = i * 4
|
center = i * 4
|
||||||
left = (center - 1) % 40
|
left = (center - 1) % 40
|
||||||
right = (center + 1) % 40
|
right = (center + 1) % 40
|
||||||
|
|
Loading…
Reference in a new issue