2019-12-16 22:14:46 +01:00
|
|
|
extends KinematicBody2D
|
2020-01-02 23:42:41 +01:00
|
|
|
# Class to control the player in basic left/right up/down movement.
|
2019-12-16 22:14:46 +01:00
|
|
|
|
|
|
|
|
2020-01-16 16:04:27 +01:00
|
|
|
var speed: float
|
2020-02-11 18:33:25 +01:00
|
|
|
onready var agent := GSAIAgentLocation.new()
|
2020-02-08 17:44:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2020-02-11 18:33:25 +01:00
|
|
|
agent.position = GSAIUtils.to_vector3(global_position)
|
2019-12-16 22:14:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
2020-01-16 09:44:44 +01:00
|
|
|
var movement := _get_movement()
|
2019-12-16 22:14:46 +01:00
|
|
|
if movement.length_squared() < 0.01:
|
|
|
|
return
|
|
|
|
|
|
|
|
move_and_slide(movement * speed)
|
2020-02-11 18:33:25 +01:00
|
|
|
agent.position = GSAIUtils.to_vector3(global_position)
|
2020-01-16 16:04:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _get_movement() -> Vector2:
|
2020-02-03 17:07:43 +01:00
|
|
|
return Vector2(
|
|
|
|
Input.get_action_strength("sf_right") - Input.get_action_strength("sf_left"),
|
|
|
|
Input.get_action_strength("sf_down") - Input.get_action_strength("sf_up"))
|