[pongwars] fix user input slowing down balls
This commit is contained in:
parent
c4e57b3b94
commit
32dba49a50
@ -263,8 +263,10 @@
|
|||||||
updatedDx *= coeff;
|
updatedDx *= coeff;
|
||||||
updatedDy *= coeff;
|
updatedDy *= coeff;
|
||||||
const speedLim = mix(100, 18, suddenDeathCoeff)
|
const speedLim = mix(100, 18, suddenDeathCoeff)
|
||||||
updatedDx = clamp(-speedLim, speedLim, updatedDx);
|
const norm = (updatedDx**2 + updatedDy**2)**(1/2)
|
||||||
updatedDy = clamp(-speedLim, speedLim, updatedDy);
|
const scalar = Math.max(norm/speedLim, 1)
|
||||||
|
updatedDx *= scalar;
|
||||||
|
updatedDy *= scalar;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,8 +276,10 @@
|
|||||||
const ct = Math.cos(theta);
|
const ct = Math.cos(theta);
|
||||||
const st = Math.sin(theta);
|
const st = Math.sin(theta);
|
||||||
if (state[color].boostEnabled) {
|
if (state[color].boostEnabled) {
|
||||||
updatedDx = (ct * updatedDx - st * updatedDy)*1.01
|
const rotDx = (ct * updatedDx - st * updatedDy);
|
||||||
updatedDy = (st * updatedDx + ct * updatedDy)*1.01
|
const rotDy = (st * updatedDx + ct * updatedDy);
|
||||||
|
updatedDx = rotDx;
|
||||||
|
updatedDy = rotDy;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { dx: updatedDx, dy: updatedDy };
|
return { dx: updatedDx, dy: updatedDy };
|
||||||
|
Loading…
Reference in New Issue
Block a user