protected void setDirection(int dir) {
        if (dir == RIGHT) {
            moveDirection = RIGHT;
            checkDirection = UP;
        }
        else if (dir == DOWN) {
            moveDirection = DOWN;
            checkDirection = RIGHT;
        }
        else if (dir == LEFT) {
            moveDirection = LEFT;
            checkDirection = DOWN;
        }
        else if (dir == UP) {
            moveDirection = UP;
            checkDirection = LEFT;
        }
    }