make menu sounds chromatic unless you go enough times

This commit is contained in:
Haze Weathers 2023-10-08 18:56:56 -04:00
parent 899a985643
commit 599117a23a

View file

@ -1,18 +1,24 @@
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:
select_sound.pitch_scale = pow(SEMITONE, RUMBLE[current_note])
current_note = posmod(current_note + 1, RUMBLE.size())
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