esw I actually came up with a solution a while ago and it seems to work well all i had to do was just modify it to Math.floor() i think Fluffypoopo originally asked a question like this
function angleCap(num){
return Math.floor(num % 360 / 90) * 90 // we use this instead of Math.round so we get angles that we like
}
// demo code
player.rotationSpeed = 0;
player.rotation = angleCap(player.rotation); // this kept being put to zero which resets everything