troll.gd 471 B

1234567891011121314
  1. extends KinematicBody2D
  2. const MOTION_SPEED = 160 # Pixels/second.
  3. const TAN30DEG = tan(deg2rad(30))
  4. func _physics_process(_delta):
  5. var motion = Vector2()
  6. motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
  7. motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
  8. motion.y *= TAN30DEG
  9. motion = motion.normalized() * MOTION_SPEED
  10. #warning-ignore:return_value_discarded
  11. move_and_slide(motion)