Fix MathUtils.LerpVector2, add cameras.

This commit is contained in:
2023-09-25 18:32:36 +02:00
parent 34c65be667
commit 6b5678cdb8
12 changed files with 139 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ public class TestGame : Game
Size = new Vector2(1280, 720)
}, new RendererSettings()
{
UseVSync = false
UseVSync = true
});
_audioBackend.Initialize();

View File

@@ -8,6 +8,14 @@ public class TestPlayer : RectangleShape2d
{
base.OnStart();
Color = Color.Cyan;
_logger.Echo("OnStart");
_camera = new Camera2d()
{
Current = true,
};
Layer.AddEntity(_camera);
}
protected override void OnUpdate(double dt)
@@ -19,7 +27,11 @@ public class TestPlayer : RectangleShape2d
var velocity = Input.GetInputDirection("left", "right", "up", "down") * _speed;
Position += velocity * (float)dt;
_camera.Position = MathUtils.LerpVector2(_camera.Position, Position, dt * 5f);
}
private Logger _logger = new(nameof(TestPlayer));
private float _speed = 200f;
private Camera2d _camera;
}