File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6969# setup for speaker pin
7070speaker = audioio .AudioOut (board .A0 )
7171
72+ # mp3 decoder setup
73+ file = "/hoopBloop0.mp3"
74+ mp3stream = audiomp3 .MP3Decoder (open (file , "rb" ))
75+
7276# state machines used in the loop
7377score = 0
7478hoops = False
99103 score += 2
100104 # an mp3 plays
101105 file = "/hoopBloop{}.mp3" .format (sample )
102- mp3stream = audiomp3 . MP3Decoder ( open (file , "rb" ) )
106+ mp3stream . file = open (file , "rb" )
103107 speaker .play (mp3stream )
104- # delay for mp3, otherwise memory error
105- time .sleep (0.5 )
106108 print ("score!" )
107109 # resets break beam
108110 beam_state = False
118120 # score text x pos if 2 digit score
119121 elif score >= 10 :
120122 score_text .x = 16
123+ elif score >= 0 :
124+ score_text .x = 23
121125 # updates score text to show current score
122126 score_text .text = score
123- time .sleep (0.1 )
127+ time .sleep (0.01 )
124128 # if a game is in progress and you press the button:
125129 if not button .value and hoops :
126130 # game stops
127131 hoops = False
128132 button_state = False
129133 # score is reset to 0
130134 score = 0
135+ score_text .text = score
131136 # display shows the start splash graphic
132137 display .show (start_group )
133138 print ("end game!" )
You can’t perform that action at this time.
0 commit comments