wipers now play sounds while wiping

added a clamp wrapper around the randf call in rain spawner
master
Zac 4 years ago
parent 7018ff856e
commit 1756b73824

@ -44,7 +44,7 @@ func _spawn_rain():
# fixes the weird scale issues on the individual drop
r.set_scale(Vector2(r.scale.x / scale.x,
r.scale.y / scale.y))
r.scale_down(randf())
r.scale_down(clamp(randf(), 0.3, 1.0))
# add the drop and increment out drop counter
add_child(r)

@ -3,17 +3,28 @@ extends Node2D
#-------------------------------
# exports
export var auto_play = false
export var dead_zones = 200
#-------------------------------
# node refs
onready var _sfx_player = $wiper_sound
#-------------------------------
# vars
var _wiping = false
var _returning = false
var _played_sound = false
var _limits = [ 90, -23 ]
var _win_size = OS.get_window_size()
var _last_mouse_pos
var _last_mouse_pos = 0.0
var _return_timer
var _sounds = {
"up": preload("res://audio/wiper_up.wav"),
"down": preload("res://audio/wiper_down.wav")
}
#-------------------------------
# overloaded functions
@ -50,6 +61,18 @@ func _process(delta):
if _last_mouse_pos != 0:
_return_timer.start()
if _last_mouse_pos >= 0.5 and \
_wiping and \
not _played_sound:
_play_wiper_sfx("up")
_played_sound = true
elif _last_mouse_pos <= 0.5 and \
(_returning or _wiping) and \
_played_sound:
_play_wiper_sfx("down")
_played_sound = false
# the actual blade moving code is in here
func _physics_process(delta):
@ -82,4 +105,10 @@ func _get_window_coverage():
# call back for the _return_timer
func _return_timer_timeout():
_returning = true
_returning = true
func _play_wiper_sfx(dir):
_sfx_player.set_stream(_sounds[dir])
_sfx_player.play()
Loading…
Cancel
Save