2014-02-23 00:28:19 +01:00
|
|
|
extends KinematicBody2D
|
|
|
|
|
2020-02-18 02:14:18 +01:00
|
|
|
const MOTION_SPEED = 160 # Pixels/second.
|
2014-02-23 00:28:19 +01:00
|
|
|
|
2019-02-26 14:22:02 +01:00
|
|
|
func _physics_process(_delta):
|
2014-02-23 00:28:19 +01:00
|
|
|
var motion = Vector2()
|
2020-02-03 04:19:14 +01:00
|
|
|
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
|
|
|
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
2020-02-18 02:14:18 +01:00
|
|
|
motion.y *= 0.57735056839 # tan(30 degrees).
|
2017-11-12 04:53:14 +01:00
|
|
|
motion = motion.normalized() * MOTION_SPEED
|
2020-02-03 04:19:14 +01:00
|
|
|
#warning-ignore:return_value_discarded
|
2017-06-25 13:00:20 +02:00
|
|
|
move_and_slide(motion)
|