Exemplo n.º 1
0
        private static bool isShiftHeld()
        {
            bool leftShift  = RawKeyboardInput.IsHeld(Keys.LeftShift);
            bool rightShift = RawKeyboardInput.IsHeld(Keys.RightShift);

            return(leftShift || rightShift);
        }
Exemplo n.º 2
0
 protected override void Update()
 {
     if (RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift))
     {
         rectRenderer.Image.Color = Color.DodgerBlue;
     }
     else
     {
         rectRenderer.Image.Color = Color.White;
     }
 }
Exemplo n.º 3
0
 protected override void Update()
 {
     if (RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift))
     {
         Object.Stop();
         updateBumpControl();
     }
     else
     {
         updateSmoothControl();
     }
 }
Exemplo n.º 4
0
 protected override void Update()
 {
     if (RawKeyboardInput.IsPressed(LeftBumpKey))
     {
         current -= RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift) ? bumpPercentage * .5f : bumpPercentage;
         OnAdjustControl(MathHelper.Lerp(Min, Max, current));
     }
     else if (RawKeyboardInput.IsPressed(RightBumpKey))
     {
         current += RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift) ? bumpPercentage * .5f : bumpPercentage;
         OnAdjustControl(MathHelper.Lerp(Min, Max, current));
     }
 }
Exemplo n.º 5
0
        private void checkKeyRepeat()
        {
            if (RawKeyboardInput.IsHeld(lastKey))   // if key from last frame is still down on this frame, we're in repeat territory
            {
                lastKeyHoldTimeSecs += Time.Seconds;

                if (!isRepeatingKey)
                {
                    handleBeginRepeatingKey();
                }
                else
                {
                    handleContinueRepeatingKey();
                }
            }
            else     // key repeat is over. RESET EVERYTHING!
            {
                resetKeyRepeat();
            }
        }
Exemplo n.º 6
0
        private void updateSmoothControl()
        {
            int newX;

            if (RawKeyboardInput.IsHeld(Keys.Left, Keys.A))
            {
                newX = -1;
            }
            else if (RawKeyboardInput.IsHeld(Keys.Right, Keys.D))
            {
                newX = 1;
            }
            else
            {
                newX = 0;
            }

            int newY;

            if (RawKeyboardInput.IsHeld(Keys.Up, Keys.W))
            {
                newY = -1;
            }
            else if (RawKeyboardInput.IsHeld(Keys.Down, Keys.S))
            {
                newY = 1;
            }
            else
            {
                newY = 0;
            }

            if (newX != lastX || newY != lastY)
            {
                Object.Velocity = new Vector2(newX * Speed, newY * Speed);
            }

            lastX = newX;
            lastY = newY;
        }