built first 2d indoor scene + added kitchen

This commit is contained in:
2025-04-30 17:36:38 +02:00
parent 752cdb1502
commit 0fcc425ace
17 changed files with 1368 additions and 17 deletions
@@ -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";
}
}
}