godot-steering-ai-framework/project/demos/arrive/ArriveDemo.gd
Francois Belair 9f945cbf85 Implement review suggestions to code
Razvan reviewed the code and suggested a number of changes to improve
readability and make facets of the code more explicit and consistent.
2020-01-12 10:20:06 -05:00

38 lines
1.1 KiB
GDScript

extends Node2D
onready var target: = $Target
onready var arriver: = $Arriver
onready var gui: = $GUI
func _ready() -> void:
gui.connect("align_tolerance_changed", self, "_on_GUI_align_tolerance_changed")
gui.connect("decel_radius_changed", self, "_on_GUI_decel_radius_changed")
gui.connect("max_speed_changed", self, "_on_GUI_max_speed_changed")
gui.connect("max_accel_changed", self, "_on_GUI_max_accel_changed")
gui.max_speed.text = str(arriver._agent.max_linear_speed)
gui.max_accel.text = str(arriver._agent.max_linear_acceleration)
gui.arrival_tolerance.text = str(arriver._arrive.arrival_tolerance)
gui.deceleration_radius.text = str(arriver._arrive.deceleration_radius)
func draw(location: Vector2) -> void:
target.draw(location)
func _on_GUI_align_tolerance_changed(value: int) -> void:
arriver._arrive.arrival_tolerance = value
func _on_GUI_decel_radius_changed(value: int) -> void:
arriver._arrive.deceleration_radius = value
func _on_GUI_max_speed_changed(value: int) -> void:
arriver._agent.max_linear_speed = value
func _on_GUI_max_accel_changed(value: int) -> void:
arriver._agent.max_linear_acceleration = value