|
|
|
@ -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()
|