Ejemplo n.º 1
0
    private void KeyMove(ref UserCmd cmd)
    {
        int moveSpeed = 0;

        if (inSpeed.active)
        {
            moveSpeed    = 127;
            cmd.buttons &= ~16;            //BUTTON_WALKING
        }
        else
        {
            cmd.buttons |= 16;
            moveSpeed    = 64;
        }

        int forward = 0;
        int side    = 0;
        int up      = 0;

        if (inStrafe.active)
        {
            side += (int)(moveSpeed * KeyState(inRight));
            side -= (int)(moveSpeed * KeyState(inLeft));
        }

        side += (int)(moveSpeed * KeyState(inMoveRight));
        side -= (int)(moveSpeed * KeyState(inMoveLeft));

        up += (int)(moveSpeed * KeyState(inUp));

        forward += (int)(moveSpeed * KeyState(inForward));
        forward -= (int)(moveSpeed * KeyState(inBack));

        // up += moveSpeed * KeyState(inDown);
        // if(side != 0){
        //  CLog.Info("move side : {0}", side);
        // }

        cmd.forwardmove = CUtils.ClampChar(forward);
        cmd.rightmove   = CUtils.ClampChar(side);
        cmd.upmove      = CUtils.ClampChar(up);
    }