inputDir
is (probably), the direction of the movement, that is (assuming speed = 1)
posNext.x = inputDir.x + posCur.x;
posNext.y = inputDir.y + posCur.y;
The actual code is
Quote:
snakeArr.unshift({ x: snakeArr[0].x + inputDir.x, y: snakeArr[0].y + inputDir.y })
inputDir = { x: 0, y: 1 };
is just an initialization: the object starts moving downward.