Skip to content

Commit dc1b9e2

Browse files
committed
add requested changes
1 parent 3788d28 commit dc1b9e2

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

PyRuler_Simon_Game/code.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,38 +85,31 @@ def read_caps():
8585

8686
def record_caps(timeout=3):
8787
start_time = time.monotonic() # start 3 second timer waiting for user input
88+
val = None
8889
while time.monotonic() - start_time < timeout:
8990
caps = read_caps()
90-
val = None
9191
for i,c in enumerate(caps):
9292
if c:
9393
val = i
94-
print("true!")
9594
time.sleep(0.1)
9695
if val is not None: # if there's input from a pad exit the timer loop
97-
break
98-
return val
96+
return val
9997

10098
def light_cap(cap, duration=0.5):
10199
# turn the LED for the selected cap on
102100
leds[cap].value = True
103-
# wait the requested amount of time
104101
time.sleep(duration)
105-
# turn the LED for the selected region off
106102
leds[cap].value = False
107103
time.sleep(duration)
108104

109105
def play_sequence(sequence):
110-
duration = 1 - len(sequence) * 0.05
111-
if duration < 0.1:
112-
duration = 0.1
106+
duration = max(0.1, 1 - len(sequence) * 0.05)
113107
for cap in sequence:
114108
light_cap(cap, duration)
115109

116110
def read_sequence(sequence):
117111
pixels.fill(green)
118112
pixels.show()
119-
#time.sleep(1)
120113
for cap in sequence:
121114
if record_caps() != cap:
122115
# the player made a mistake!

0 commit comments

Comments
 (0)