@Override
    public void actionPerformed(ActionEvent e) {
        Random r = new Random();

        int d = r.nextInt() % 5;
        switch (d) {
            case 0:
                break;
            case 1:
                // move right
                if (dx < 0) {
                    dx = -dx; // if moving left, move right
                }
                break;
            case 2:
                //move left
                if (dx > 0) {
                    dx = -dx; // if moving right, move left
                }
                break;
            case 3:
                // move up
                if (dy > 0) {
                    dy = -dy; // if moving down, move up
                }
                break;
            case 4:
                // move down
                if (dy < 0) {
                    dy = -dy; // if moving up, move down
                }
                break;
        }
    }