You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed in VertexClientPE.Utils.Player.isCollidedHorizontally was the while(x < 1) x += 1; and those similar ones directly next to it could be optimized.
I don't know if readability is extemely important, but as I noticed that I had one rounding error when testing just the first two whiles for x (and this was very close to the target number as well in whole numbers, and the fractional part was somewhere between zero to two digits long), my optimized fix actually would help speed up the game if the input value is normally going to be high, and especially if the Javascript environment is already running slow.
Note that your code might have the chance to be rewritten (optimized while still being readable) as well around there if the number actually stays accurate enough. This is mainly about the if(Math.round(x * 100) == 31) x -= 0.01; section below it, yet I cannot be certain if it really is no longer necessary as I haven't tested the fix myself.
Now this is a sample to replace that offending line (and its opposite direction) I first mentioned.
// The equiv. for your current 'while(x < 1) x += 1;' and 'while(x > 1) x -= 1;'x=x-Math.floor(x)||1;// Use the following instead if the range is really '[0, 1)'x-=Math.floor(x);
-snip-
The text was updated successfully, but these errors were encountered:
I noticed in VertexClientPE.Utils.Player.isCollidedHorizontally was the
while(x < 1) x += 1;
and those similar ones directly next to it could be optimized.I don't know if readability is extemely important, but as I noticed that I had one rounding error when testing just the first two
while
s forx
(and this was very close to the target number as well in whole numbers, and the fractional part was somewhere between zero to two digits long), my optimized fix actually would help speed up the game if the input value is normally going to be high, and especially if the Javascript environment is already running slow.Note that your code might have the chance to be rewritten (optimized while still being readable) as well around there if the number actually stays accurate enough. This is mainly about the
if(Math.round(x * 100) == 31) x -= 0.01;
section below it, yet I cannot be certain if it really is no longer necessary as I haven't tested the fix myself.Now this is a sample to replace that offending line (and its opposite direction) I first mentioned.
-snip-
The text was updated successfully, but these errors were encountered: