Skip to content

Commit a463aab

Browse files
authored
change read_region()
add time.sleep(.3) delays and break(s) to exit loop upon touch. (my opinion) more responsive game. do not have to wait for timer to expire (30 seconds) between touches.
1 parent 812002d commit a463aab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CPX_Simon_Game/code.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,32 @@ def read_region(timeout=30):
5959
while time.time() - start_time < timeout:
6060
if cpx.touch_A1:
6161
val = PAD_REGION['A1']
62+
time.sleep(.3)
63+
break
6264
elif cpx.touch_A2:
6365
val = PAD_REGION['A2']
66+
time.sleep(.3)
67+
break
6468
elif cpx.touch_A3:
6569
val = PAD_REGION['A3']
70+
time.sleep(.3)
71+
break
6672
elif cpx.touch_A4:
6773
val = PAD_REGION['A4']
74+
time.sleep(.3)
75+
break
6876
elif cpx.touch_A5:
6977
val = PAD_REGION['A5']
78+
time.sleep(.3)
79+
break
7080
elif cpx.touch_A6:
7181
val = PAD_REGION['A6']
82+
time.sleep(.3)
83+
break
7284
elif cpx.touch_A7:
7385
val = PAD_REGION['A7']
86+
time.sleep(.3)
87+
break
7488
return val
7589

7690
def play_sequence(sequence):

0 commit comments

Comments
 (0)