Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using large non-square width and heights (especially width) the joystick has very little movement in one axis #40

Open
tyeth opened this issue Jul 29, 2022 · 0 comments

Comments

@tyeth
Copy link

tyeth commented Jul 29, 2022

Laptop 1980x1200, desktop chrome full size, setting size of div to 60vw 60vh, results in a short wide box, and the joystick movement space is very limited in vertical direction. I've made this change, and also set a Max and Min on the returned X and Y.

I changed the calculation for internalRadius and all is well:

var smallestDimension = Math.min(canvas.width,canvas.height);
var internalRadius = (smallestDimension-((smallestDimension/2)+10))/2;

This is the minor change to X / Y to be capped at +/-100

/**
* @desc Normalizzed value of X move of stick
* @return Integer from -100 to +100
*/
this.GetX = function ()
{
    return Math.max(-100,Math.min(100, (100*((movedX - centerX)/maxMoveStick)))).toFixed();
};

/**
* @desc Normalizzed value of Y move of stick
* @return Integer from -100 to +100
*/
this.GetY = function ()
{
    return Math.max(-100,Math.min(100, ((100*((movedY - centerY)/maxMoveStick))*-1))).toFixed();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant