Update test game to showcase camera system.

This commit is contained in:
2023-09-25 18:54:17 +02:00
parent 8aab1132b6
commit 092d01dcae
4 changed files with 55 additions and 13 deletions

View File

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