File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 69
69
# setup for speaker pin
70
70
speaker = audioio .AudioOut (board .A0 )
71
71
72
+ # mp3 decoder setup
73
+ file = "/hoopBloop0.mp3"
74
+ mp3stream = audiomp3 .MP3Decoder (open (file , "rb" ))
75
+
72
76
# state machines used in the loop
73
77
score = 0
74
78
hoops = False
99
103
score += 2
100
104
# an mp3 plays
101
105
file = "/hoopBloop{}.mp3" .format (sample )
102
- mp3stream = audiomp3 . MP3Decoder ( open (file , "rb" ) )
106
+ mp3stream . file = open (file , "rb" )
103
107
speaker .play (mp3stream )
104
- # delay for mp3, otherwise memory error
105
- time .sleep (0.5 )
106
108
print ("score!" )
107
109
# resets break beam
108
110
beam_state = False
118
120
# score text x pos if 2 digit score
119
121
elif score >= 10 :
120
122
score_text .x = 16
123
+ elif score >= 0 :
124
+ score_text .x = 23
121
125
# updates score text to show current score
122
126
score_text .text = score
123
- time .sleep (0.1 )
127
+ time .sleep (0.01 )
124
128
# if a game is in progress and you press the button:
125
129
if not button .value and hoops :
126
130
# game stops
127
131
hoops = False
128
132
button_state = False
129
133
# score is reset to 0
130
134
score = 0
135
+ score_text .text = score
131
136
# display shows the start splash graphic
132
137
display .show (start_group )
133
138
print ("end game!" )
You can’t perform that action at this time.
0 commit comments