[pongwars] fix user input slowing down balls

This commit is contained in:
dogeystamp 2024-01-30 14:23:50 -05:00
parent c4e57b3b94
commit 32dba49a50

View File

@ -263,8 +263,10 @@
updatedDx *= coeff;
updatedDy *= coeff;
const speedLim = mix(100, 18, suddenDeathCoeff)
updatedDx = clamp(-speedLim, speedLim, updatedDx);
updatedDy = clamp(-speedLim, speedLim, updatedDy);
const norm = (updatedDx**2 + updatedDy**2)**(1/2)
const scalar = Math.max(norm/speedLim, 1)
updatedDx *= scalar;
updatedDy *= scalar;
}
}
@ -274,8 +276,10 @@
const ct = Math.cos(theta);
const st = Math.sin(theta);
if (state[color].boostEnabled) {
updatedDx = (ct * updatedDx - st * updatedDy)*1.01
updatedDy = (st * updatedDx + ct * updatedDy)*1.01
const rotDx = (ct * updatedDx - st * updatedDy);
const rotDy = (st * updatedDx + ct * updatedDy);
updatedDx = rotDx;
updatedDy = rotDy;
}
return { dx: updatedDx, dy: updatedDy };