Movement refactor

This commit is contained in:
2025-08-30 23:06:12 +02:00
committed by GitHub
parent d786ef4c22
commit 88c7a0a055
41 changed files with 656 additions and 122 deletions

View File

@@ -0,0 +1,29 @@
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class SpaceshipMovementAbility : MovementAbility
{
[Export] public float MaxSpeed { get; set; } = 300f;
[Export] public float Acceleration { get; set; } = 2000f;
[Export] public float Friction { get; set; } = 1700f;
public override Vector2 ProcessMovement(Vector2 currentVelocity, double delta)
{
if (_input == null) return Vector2.Zero;
var inputVector = _input.MoveDirection;
if (inputVector != Vector2.Zero)
{
currentVelocity = currentVelocity.MoveToward(inputVector * MaxSpeed, Acceleration * (float)delta);
}
else
{
currentVelocity = currentVelocity.MoveToward(Vector2.Zero, Friction * (float)delta);
}
return currentVelocity;
}
}