Пример #1
0
        public FlyController(Body body, float force = .5f, float max = 3, float linearDamping = 0)
        {
            Force = force;
            Body = body;
            _engine = Add(new BodyController(body, max));

            Add(new KeyBinding(Keys.W, () => _engine.ApplyForce(0, -Force), true));
            Add(new KeyBinding(Keys.S, () => _engine.ApplyForce(0, Force), true));
            Add(new KeyBinding(Keys.A, () => _engine.ApplyForce(-Force, 0), true));
            Add(new KeyBinding(Keys.D, () => _engine.ApplyForce(Force, 0), true));

            Add(new KeyBinding(Keys.LeftShift, StartBreak, StopBreaking, Break));
            Add(new KeyBinding(Keys.Space, PrepareBoost, StartBoost, Break));

            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(0, -force * v.Y / 10)));
            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(0, -force * v.Y)));
            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(force * v.X, 0)));
            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(force * v.X, 0)));

            _boostTimer = Create<Timeline>();
        }
Пример #2
0
 public SurfaceMovementControl(Body body, float force = 1f, float maxVelocity = 1f)
 {
     _force = force;
     _body = body;
     _engine = new BodyController(_body, maxVelocity);
 }