diff --git a/src/Player.cs b/src/Player.cs index 2f3dd7b..506fcae 100644 --- a/src/Player.cs +++ b/src/Player.cs @@ -3,37 +3,20 @@ using System; public class Player : KinematicBody2D { - private Vector2 velocity; - private Vector2 strength; [Export] - public int speed = 400; + public int speed = 500; public override void _PhysicsProcess(float delta) { - GetInput(); - MoveAndCollide(velocity * strength * delta); - } - - public void GetInput() - { - velocity = new Vector2(); - strength = new Vector2(Input.GetActionStrength("move_right") - Input.GetActionStrength("move_left"),Input.GetActionStrength("move_up") - Input.GetActionStrength("move_down")).LimitLength(1).Abs(); - if (Input.IsActionPressed("move_left")) - { - velocity.x -= speed; - } - if (Input.IsActionPressed("move_right")) - { - velocity.x += speed; - } - if (Input.IsActionPressed("move_up")) - { - velocity.y -= speed; - } - if (Input.IsActionPressed("move_down")) - { - velocity.y += speed; - } + MoveAndCollide(new Vector2 + ( + Input.GetActionStrength("move_right") + - Input.GetActionStrength("move_left"), + Input.GetActionStrength("move_down") + - Input.GetActionStrength("move_up") + ).LimitLength(1) + * speed * delta + ); } public override void _Process(float delta)