revo-jailbreak/objects/hud/menu_sounds.gd

27 lines
816 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
Audio.ac_menu.pitch_scale = pow(SEMITONE, tune[current_note])
Audio.play_sound(Audio.a_select,Audio.ac_menu)
current_note = posmod(current_note + 1, tune.size())
notes_till_rumble -= 1
else:
can_play = true
func play_confirm_sound():
Audio.ac_menu.pitch_scale = 1
Audio.play_sound(Audio.a_confirm,Audio.ac_menu)