Update final/main4emaj.py
This commit is contained in:
@@ -15,6 +15,36 @@ drive_base.use_gyro(True)
|
|||||||
color_sensor = ColorSensor(Port.F)
|
color_sensor = ColorSensor(Port.F)
|
||||||
hub.speaker.volume(50) # Set the volume of the speaker
|
hub.speaker.volume(50) # Set the volume of the speaker
|
||||||
|
|
||||||
|
cn = {
|
||||||
|
"Cs3": 138.59,
|
||||||
|
"D3": 146.83,
|
||||||
|
"Ds3": 155.56,
|
||||||
|
"E3": 164.81,
|
||||||
|
"F3": 174.61,
|
||||||
|
"Fs3": 185.00,
|
||||||
|
"G3": 196.00,
|
||||||
|
"Gs3": 207.65,
|
||||||
|
"A3": 220.00,
|
||||||
|
"As3": 233.08,
|
||||||
|
"B3": 246.94,
|
||||||
|
"C4": 261.63,
|
||||||
|
"Cs4": 277.18,
|
||||||
|
"D4": 293.66,
|
||||||
|
"Ds4": 311.13,
|
||||||
|
"E4": 329.63,
|
||||||
|
"F4": 349.23,
|
||||||
|
"Fs4": 369.99,
|
||||||
|
"G4": 392.00,
|
||||||
|
"Gs4": 415.30,
|
||||||
|
"A4": 440.00,
|
||||||
|
"As4": 466.16,
|
||||||
|
"B4": 493.88,
|
||||||
|
"C5": 523.25,
|
||||||
|
"Cs5": 554.37
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def Run1():
|
async def Run1():
|
||||||
left_arm.run_angle(1000, 300)
|
left_arm.run_angle(1000, 300)
|
||||||
right_arm.run_angle(1000,500)
|
right_arm.run_angle(1000,500)
|
||||||
@@ -51,6 +81,7 @@ async def Run2():
|
|||||||
await drive_base.turn(45)
|
await drive_base.turn(45)
|
||||||
await drive_base.straight(50)
|
await drive_base.straight(50)
|
||||||
await right_arm.run_angle(350,-1000)
|
await right_arm.run_angle(350,-1000)
|
||||||
|
await drive_base.straight(-100)
|
||||||
await drive_base.turn(-100)
|
await drive_base.turn(-100)
|
||||||
await drive_base.straight(-600)
|
await drive_base.straight(-600)
|
||||||
async def Run3():
|
async def Run3():
|
||||||
@@ -97,23 +128,24 @@ async def play_victory_fanfare():
|
|||||||
async def play_level_up():
|
async def play_level_up():
|
||||||
"""Upward scale for level completion"""
|
"""Upward scale for level completion"""
|
||||||
notes = [
|
notes = [
|
||||||
(277, 100),
|
(cn["Cs4"], 100),
|
||||||
(330, 100),
|
(cn["E4"], 100),
|
||||||
(277, 100),
|
(cn["Cs4"], 100),
|
||||||
(554, 100),
|
(cn["Cs5"], 100),
|
||||||
(277, 100),
|
(cn["Cs4"], 100),
|
||||||
(413, 100),
|
(cn["Gs4"], 100),
|
||||||
(330, 100),
|
(cn["E4"], 100),
|
||||||
(277, 100),
|
(cn["Cs4"], 100),
|
||||||
(413, 100),
|
(cn["Gs4"], 100),
|
||||||
(277, 100),
|
(cn["Cs4"], 100),
|
||||||
(554, 100),
|
(cn["Cs5"], 100),
|
||||||
(413, 100),
|
(cn["Gs4"], 100),
|
||||||
(277, 100),
|
(cn["Cs4"], 100),
|
||||||
(413, 100),
|
(cn["Gs4"], 100),
|
||||||
(554, 100),
|
(cn["Cs5"], 100),
|
||||||
(413, 100)
|
(cn["Gs4"], 100)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
for freq, duration in notes:
|
for freq, duration in notes:
|
||||||
await hub.speaker.beep(freq, duration)
|
await hub.speaker.beep(freq, duration)
|
||||||
@@ -121,10 +153,11 @@ async def play_level_up():
|
|||||||
async def play_success_chime():
|
async def play_success_chime():
|
||||||
"""Simple success notification"""
|
"""Simple success notification"""
|
||||||
notes = [
|
notes = [
|
||||||
(659, 150), # E5
|
(cn["E4"], 150),
|
||||||
(830, 150), # G♯5
|
(cn["Gs4"], 150),
|
||||||
(987, 300), # B♭5
|
(cn["B4"], 300),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
for freq, duration in notes:
|
for freq, duration in notes:
|
||||||
await hub.speaker.beep(freq, duration)
|
await hub.speaker.beep(freq, duration)
|
||||||
@@ -132,8 +165,8 @@ async def play_success_chime():
|
|||||||
async def play_ta_da():
|
async def play_ta_da():
|
||||||
"""Classic "ta-da!" sound"""
|
"""Classic "ta-da!" sound"""
|
||||||
notes = [
|
notes = [
|
||||||
(494, 200), # B♭4
|
(cn["B3"], 200), # B4
|
||||||
(659, 400), # E5
|
(cn["E4"], 400), # E5
|
||||||
]
|
]
|
||||||
|
|
||||||
for freq, duration in notes:
|
for freq, duration in notes:
|
||||||
@@ -141,24 +174,31 @@ async def play_ta_da():
|
|||||||
await wait(100)
|
await wait(100)
|
||||||
async def play_power_up():
|
async def play_power_up():
|
||||||
"""Rising power-up sound"""
|
"""Rising power-up sound"""
|
||||||
for freq in range(200, 800, 50):
|
frequencies = [
|
||||||
|
164.81, 207.65, 246.94, 329.63, 415.30, 493.88
|
||||||
|
]
|
||||||
|
|
||||||
|
for freq in frequencies:
|
||||||
await hub.speaker.beep(freq, 50)
|
await hub.speaker.beep(freq, 50)
|
||||||
await wait(10)
|
await wait(10)
|
||||||
await hub.speaker.beep(1000, 200)
|
|
||||||
|
|
||||||
|
await hub.speaker.beep(659.24, 200)
|
||||||
async def play_rickroll_inspired():
|
async def play_rickroll_inspired():
|
||||||
"""Fun 80s-style dance beat inspired sound"""
|
"""Fun 80s-style dance beat inspired sound"""
|
||||||
# Upbeat bouncy rhythm
|
# Upbeat bouncy rhythm
|
||||||
pattern = [
|
pattern = [
|
||||||
(494, 200), (554, 200), (622, 200), (659, 200),
|
(cn["B3"], 200), (cn["Cs4"], 200), (cn["Ds4"], 200), (cn["E4"], 200),
|
||||||
(554, 200), (494, 200), (439, 200), (494, 300),
|
(cn["Cs4"], 200), (cn["B3"], 200), (cn["A3"], 200), (cn["B3"], 300),
|
||||||
(554, 200), (494, 200), (439, 200), (416, 400),
|
(cn["Cs4"], 200), (cn["B3"], 200), (cn["A3"], 200), (cn["Gs3"], 400),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for freq, duration in pattern:
|
for freq, duration in pattern:
|
||||||
await hub.speaker.beep(freq, duration)
|
await hub.speaker.beep(freq, duration)
|
||||||
await wait(50)
|
await wait(50)
|
||||||
async def celebrate_mission_complete(sound_type=CelebrationSound.SUCCESS_CHIME):
|
async def celebrate_mission_complete(sound_type=CelebrationSound.RICKROLL_INSPIRED):
|
||||||
"""
|
"""
|
||||||
Main celebration function to call after completing a mission.
|
Main celebration function to call after completing a mission.
|
||||||
Plays a sound and shows light animation.
|
Plays a sound and shows light animation.
|
||||||
|
|||||||
Reference in New Issue
Block a user