using Godot; using System; public partial class Player : CharacterBody2D { [Export] float Speed; public float PixelSize = 1.0f; public override void _PhysicsProcess(double delta) { Vector2 velocity = Velocity; if(Input.IsActionPressed("quit")) { GetTree().Quit(); } Vector2 direction = Input.GetVector("left", "right", "up", "down"); direction = direction.Normalized(); if (direction != Vector2.Zero) { velocity = direction * Speed * (float)delta; } else { velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); velocity.Y = Mathf.MoveToward(Velocity.Y, 0, Speed); } Velocity = velocity; MoveAndSlide(); Position = Position.Round(); } }