hero-mark-2/objects/hud/menu_sounds.gd

26 lines
733 B
GDScript

extends Node
const SEMITONE := 1.05946
const CHROMATIC := [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]
const RUMBLE := [0.0, 0.0, 5.0, 7.0, 10.0, 0.0, 5.0, 7.0, 10.0, 7.0]
var can_play: bool = false
var current_note: int = 0
var notes_till_rumble: int = 48
onready var select_sound: AudioStreamPlayer = $"%SelectSound"
func play_select_sound():
if can_play:
var tune = CHROMATIC if notes_till_rumble > 0 else RUMBLE
if notes_till_rumble == 0:
current_note = 0
select_sound.pitch_scale = pow(SEMITONE, tune[current_note])
select_sound.play()
current_note = posmod(current_note + 1, tune.size())
notes_till_rumble -= 1
else:
can_play = true
func play_confirm_sound():
$"%ConfirmSound".play()