using Godot; namespace Babushka.scripts.CSharp.Common.CharacterControls; public partial class Player2D : Node2D { [Export] private float _speed = 100f; [Export] private AnimatedSprite2D _sprite; private bool anyActionPressed; public override void _Process(double delta) { anyActionPressed = false; if (Input.IsActionPressed("move_right")) { Position = new Vector2(Position.X + (_speed * (float)delta), Position.Y); _sprite.FlipH = false; _sprite.Animation = "side_walking"; anyActionPressed = true; } if (Input.IsActionPressed("move_left")) { Position = new Vector2(Position.X - (_speed * (float)delta), Position.Y); _sprite.FlipH = true; _sprite.Animation = "side_walking"; anyActionPressed = true; } if (Input.IsActionPressed("move_up")) { Position = new Vector2(Position.X, Position.Y - (_speed * (float)delta)); _sprite.Animation = "back walking"; anyActionPressed = true; } if (Input.IsActionPressed("move_down")) { Position = new Vector2(Position.X, Position.Y + (_speed * (float)delta)); _sprite.Animation = "front walking"; anyActionPressed = true; } if (anyActionPressed) { _sprite.Play(); } else { _sprite.Animation = "front idle"; } } }