I reading this code, and have this line
switch (!!up + !!left) {
what is !!
operator ? two logical NOT ?
yes, it's two nots.
!!a
is 1
if a
is non-zero and 0
if a
is 0
You can think of !!
as clamping, as it were, to {0,1}
. I personally find the usage a bad attempt to appear fancy.