public void pre_move(int key)
    {
        if ((key == KeyEvent.VK_LEFT) && (!rightDirection))
        {
                leftDirection = true;
                upDirection = false;
                downDirection = false;
        }

        if ((key == KeyEvent.VK_RIGHT) && (!leftDirection))
        {
                rightDirection = true;
                upDirection = false;
                downDirection = false;
        }

        if ((key == KeyEvent.VK_UP) && (!downDirection))
        {
                upDirection = true;
                rightDirection = false;
                leftDirection = false;
        }

        if ((key == KeyEvent.VK_DOWN) && (!upDirection))
        {
                downDirection = true;
                rightDirection = false;
                leftDirection = false;
        }
    }