Beyond_Beyaan.Camera.MouseWheel C# (CSharp) Method

MouseWheel() public method

public MouseWheel ( int direction, float mouseX, float mouseY ) : void
direction int
mouseX float
mouseY float
return void
        public void MouseWheel(int direction, float mouseX, float mouseY)
        {
            if (direction > 0)
            {
                if (ZoomDistance < 1)
                {
                    float oldScale = ZoomDistance;
                    ZoomDistance += 0.05f;
                    if (ZoomDistance >= 1)
                    {
                        ZoomDistance = 1;
                    }

                    float xScale = mouseX / _windowWidth;
                    float yScale = mouseY / _windowHeight;

                    _cameraX += ((_windowWidth / oldScale) - (_windowWidth / ZoomDistance)) * xScale;
                    _cameraY += ((_windowHeight / oldScale) - (_windowHeight / ZoomDistance)) * yScale;
                }
            }
            else
            {
                if (ZoomDistance > MaxZoom)
                {
                    float oldScale = ZoomDistance;
                    ZoomDistance -= 0.05f;
                    if (ZoomDistance < MaxZoom)
                    {
                        ZoomDistance = MaxZoom;
                    }

                    _cameraX -= ((_windowWidth / ZoomDistance) - (_windowWidth / oldScale)) / 2;
                    _cameraY -= ((_windowHeight / ZoomDistance) - (_windowHeight / oldScale)) / 2;
                }
            }
            CheckPosition();
        }