Files
Voile/TestGame/TestPlayer.cs

41 lines
1.1 KiB
C#

using DaggerFramework;
using DaggerFramework.SceneGraph;
using DaggerFramework.Utils;
public class TestPlayer : RectangleShape2d
{
protected override void OnStart()
{
base.OnStart();
Color = Color.Cyan;
_logger.Echo("OnStart");
// _camera = new Camera2d()
// {
// Current = true,
// };
// Layer.AddEntity(_camera);
}
protected override void OnUpdate(double dt)
{
base.OnUpdate(dt);
// var sprinting = Input.IsActionDown("sprint");
// _speed = sprinting ? 400f : 200f;
// var velocity = Input.GetInputDirection("left", "right", "up", "down") * _speed;
// Position += velocity * (float)dt;
// _camera.Position = MathUtils.LerpVector2(_camera.Position, Position, dt * 5f);
var mousePos = Input.GetMousePosition();
Position = MathUtils.LerpVector2(Position, mousePos, dt * 5f);
Rotation += (float)dt * 100f;
}
private Logger _logger = new(nameof(TestPlayer));
private float _speed = 200f;
private Camera2d _camera;
}