I often face the problem of stacked if-statements that look repetitive, but usually can't find an easy way to simplify it.    if (keyState[BOTTOM]){        dig_direction = BOTTOM;        startDig(SIZE / 2 - x % SIZE, DIG_DEPTH);    } else if (keyState[RIGHT] && isTouching[RIGHT]){        dig_direction = RIGHT;        startDig(DIG_DEPTH, 0);    } else if (keyState[LEFT] && isTouching[LEFT]){        dig_direction = LEFT;        startDig(-DIG_DEPTH, 0);    }
If-statement consolidation
javascript;design patterns;game