Update twist_scrimmage.py

This commit is contained in:
2025-10-11 02:16:06 +00:00
parent 9a06677dcc
commit dd0070d8e2

View File

@@ -167,10 +167,10 @@ class CelebrationSound:
async def play_victory_fanfare():
"""Classic victory fanfare"""
notes = [
(330, 200), # E4
(330, 100), # E4
(330, 100), # E4
(440, 600), # A4
(cn["B3"], 200),
(cn["B3"], 100),
(cn["B3"], 100),
(cn["E4"], 600)
]
for freq, duration in notes:
@@ -216,13 +216,24 @@ async def play_success_chime():
async def play_ta_da():
"""Classic "ta-da!" sound"""
notes = [
(cn["B3"], 200), # B4
(cn["E4"], 400), # E5
(cn["Cs4"], 200),
(cn["Ds4"], 200),
(cn["E4"], 200),
(cn["Ds4"], 200),
(cn["E4"], 200),
(cn["Fs4"], 400),
(cn["Gs4"], 600),
(cn["Fs4"], 400),
(cn["Gs4"], 200),
(cn["A4"], 200),
(cn["B4"], 200),
(cn["C5"], 200),
(cn["Cs5"], 200)
]
for freq, duration in notes:
await hub.speaker.beep(freq, duration)
await wait(100)
#await wait(100)
async def play_power_up():
"""Rising power-up sound"""
frequencies = [
@@ -239,19 +250,19 @@ async def play_rickroll_inspired():
"""Fun 80s-style dance beat inspired sound"""
# Upbeat bouncy rhythm
pattern = [
(cn["B3"], 200), (cn["Cs4"], 200), (cn["Ds4"], 200), (cn["E4"], 200),
(cn["Cs4"], 200), (cn["B3"], 200), (cn["A3"], 200), (cn["B3"], 300),
(cn["Cs4"], 200), (cn["B3"], 200), (cn["A3"], 200), (cn["Gs3"], 400),
(cn["Gs3"], 200), (cn["A3"], 200), (cn["B3"], 200), (cn["Cs4"], 200),
(cn["A3"], 200), (cn["Gs3"], 200), (cn["Fs3"], 200), (cn["Gs3"], 400),
(cn["A3"], 200), (cn["Gs3"], 200), (cn["Fs3"], 200), (cn["E3"], 400),
]
for freq, duration in pattern:
await hub.speaker.beep(freq, duration)
await wait(50)
#await wait(50)
# Basically a big if else statement that calls the functions above
async def celebrate_mission_complete(sound_type=CelebrationSound.RICKROLL_INSPIRED):
async def celebrate_mission_complete(sound_type=CelebrationSound.WAITING_SOUND):
"""
Main celebration function to call after completing a mission.
Plays a sound and shows light animation.
@@ -323,7 +334,7 @@ async def main():
elif color_detected == Color.RED:
print('Running Mission 6')
await Run6()
await celebrate_mission_complete(CelebrationSound.POWER_UP)
await celebrate_mission_complete(CelebrationSound.TA_DA)
else:
hub.light.off()
left_motor.stop()
@@ -331,6 +342,4 @@ async def main():
else:
print("No color was detected.")
await wait(100) # prevent loop from iterating fast
# Main execution loop
run_task(main())