aescending key pitch

This commit is contained in:
Haze Weathers 2023-12-26 21:16:54 -05:00
parent 2774decaf9
commit 403924d210
2 changed files with 21 additions and 4 deletions

View file

@ -51,9 +51,10 @@ var loop_section = null
var has_looped = false var has_looped = false
#Plays a sound #Plays a sound
func play_sound(snd,player): func play_sound(snd: AudioStream, player: AudioStreamPlayer, pitch: float = 1.0):
player.set_stream(snd) player.stream = snd
player._set_playing(true) player.pitch_scale = pitch
player.play()
#Play music, if same track is already playing do nothing #Play music, if same track is already playing do nothing
func play_music(song): func play_music(song):

View file

@ -1,5 +1,15 @@
extends Node2D extends Node2D
const SEMITONE := 1.05946
const TIMEOUT := 1000
const MAX_PITCH := 5.0
const STATIC = {
pitch = -2.0,
timeout = -1,
}
func _ready(): func _ready():
#Sync all coinframes #Sync all coinframes
$AnimatedSprite.play() $AnimatedSprite.play()
@ -10,5 +20,11 @@ func _on_Area2D_body_entered(body: Node) -> void:
if body.is_in_group("player"): if body.is_in_group("player"):
Game.keys += 1 Game.keys += 1
Game.score += 5 Game.score += 5
Audio.play_sound(Audio.a_key,Audio.ac_collectible) # pitch increase
if Time.get_ticks_msec() < STATIC.timeout:
STATIC.pitch = min(STATIC.pitch + 1.0, MAX_PITCH)
else:
STATIC.pitch = -2.0
STATIC.timeout = Time.get_ticks_msec() + TIMEOUT
Audio.play_sound(Audio.a_key,Audio.ac_collectible, pow(SEMITONE, STATIC.pitch))
queue_free() queue_free()