diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/audio/play_random.gd | 1 | ||||
-rw-r--r-- | client/map/progress.gd | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/client/audio/play_random.gd b/client/audio/play_random.gd index 04ba006a..e51b77ac 100644 --- a/client/audio/play_random.gd +++ b/client/audio/play_random.gd @@ -63,6 +63,7 @@ func stop_all(): s.stop() func start_autoplay(): + if autoplay: return autoplay = true play_random() diff --git a/client/map/progress.gd b/client/map/progress.gd index 438e5ac8..c9b432fb 100644 --- a/client/map/progress.gd +++ b/client/map/progress.gd @@ -21,6 +21,7 @@ extends MeshInstance3D var beep_node: PlayRandom = load("res://audio/play_random.tscn").instantiate() var speed := 0. var position_ := 0. +var warn := false func _ready(): add_child(beep_node) @@ -28,19 +29,21 @@ func _ready(): beep_node.volume_db = -12 beep_node.setup([load("res://audio/beep.ogg")]) -func update(new_position: float, new_speed: float, warn: bool): +func update(new_position: float, new_speed: float, new_warn: bool): speed = new_speed position_ = new_position + warn = new_warn var mat: ShaderMaterial = get_active_material(0) mat.set_shader_parameter("progress", position_) mat.set_shader_parameter("bad", warn) - - if warn and speed > 0: beep_node.start_autoplay() - else: beep_node.stop_autoplay() func _process(delta: float): position_ += delta * speed + var time_remaining = (1 - position_) / speed + + if warn and speed > 0 and time_remaining < 5.: beep_node.start_autoplay() + else: beep_node.stop_autoplay() var mat: ShaderMaterial = get_active_material(0) mat.set_shader_parameter("progress", position_) |