Exemple #1
0
        protected override async ValueTask UpdateCore(GameContext game)
        {
            var dt = (float)game.GameTime.ElapsedMilliseconds / 1000;

            _rotationVelocity         += RotationSpeed * dt;
            _rotationVelocity         *= (1f - dt * RotationDrag);
            _transform.Local.Rotation += _rotationVelocity * dt;

            var dir = new Vector2(MathF.Sin(_transform.Local.Rotation), -MathF.Cos(_transform.Local.Rotation));

            var traction = dir * this.Thrust;

            var acceleration = traction / Mass;

            _velocity += acceleration * dt;
            _velocity *= (1 - dt * Drag);
            _velocity  = Vector2Utils.ClampMagnitude(ref _velocity, MaxSpeed);

            _transform.Local.Position += _velocity * dt;
        }
 public void Aim(Vector2 aimDirection)
 {
     this.aimDirection = Vector2Utils.ClampMagnitude(aimDirection, 1, 1);
 }