built first 2d indoor scene + added kitchen
This commit is contained in:
@@ -5,16 +5,52 @@ 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)
|
||||
{
|
||||
if (Input.IsActionPressed("move_right"))
|
||||
anyActionPressed = false;
|
||||
|
||||
if (Input.IsActionPressed("move_right"))
|
||||
{
|
||||
Position = new Vector2(Position.X + (_speed * (float)delta), Position.Y);
|
||||
if (Input.IsActionPressed("move_left"))
|
||||
_sprite.FlipH = false;
|
||||
_sprite.Animation = "side_walking";
|
||||
anyActionPressed = true;
|
||||
}
|
||||
|
||||
if (Input.IsActionPressed("move_left"))
|
||||
{
|
||||
Position = new Vector2(Position.X - (_speed * (float)delta), Position.Y);
|
||||
if (Input.IsActionPressed("move_up"))
|
||||
_sprite.FlipH = true;
|
||||
_sprite.Animation = "side_walking";
|
||||
anyActionPressed = true;
|
||||
}
|
||||
|
||||
if (Input.IsActionPressed("move_up"))
|
||||
{
|
||||
Position = new Vector2(Position.X, Position.Y - (_speed * (float)delta));
|
||||
if (Input.IsActionPressed("move_down"))
|
||||
_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";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user