pero ahora necesito hcer un menu de la dificultad
tiene que ser una ventana para q elija la dificultad (facil medio dificil)
bueno el juego ya lo tengo pero no se hacer ese menu
les agradeceria mucho si me ayudaran
ese es el juego
esta en facil
al elegir supuestamente medio se disminuyen los disparos...
Código
package combate; import java.awt.*; import java.awt.event.*; import java.io.IOException; import javax.swing.JFrame; import javax.swing.JOptionPane; public class combate { int puntero = 12; PanelCombate panel = new PanelCombate(); f.add(panel); } }); f.setTitle("Combate Naval "); f.setCursor(puntero); f.setSize(450, 450); f.show(); } } Casilla tablero[][]; boolean naves [][]; boolean maquina[][]; int pos, disparos, fallos,aciertos = 0; PanelCombate() { int f, c; tablero = new Casilla[11][11]; naves = new boolean[11][11]; pos = seleccion(); for (f = 0; f < 11; f++) { for (c = 0; c < 11; c++) { naves[f][c] = false; tablero[f][c] = new Casilla(""); add(tablero[f][c]); tablero[f][c].addActionListener(new AccionBoton(this, c, f)); } } for (int i = 1; i <= 3; i++) { switch (i) { case 1: try{ if (tipo > 2) { if (f == 11) { naves[f - 1][c] = true; } else { naves[f + 1][c] = true; } } else { if (c == 11) { naves[f][c - 1] = true; } else { naves[f][c + 1] = true; } }} } break; case 2: try{ if (tipo > 2) { if (f == 9) { naves[f - 1][c] = true; naves[f - 2][c] = true; naves[f - 3][c] = true; } else { naves[f + 1][c] = true; naves[f + 2][c] = true; naves[f + 3][c] = true; } } else { if (c == 9) { naves[f][c - 1] = true; naves[f][c - 2] = true; naves[f][c - 3] = true; } else { naves[f][c + 1] = true; naves[f][c + 2] = true; naves[f][c + 3] = true; } } break; } } case 3: try{ if (f == 9) { naves[f - 1][c] = true; naves[f - 1][c + 1] = true; } else { naves[f + 1][c] = true; naves[f + 1][c - 1] = true; } break; } } } naves[f][c] = true; } } private int seleccion() { int a = 9; return a; } boolean aciertos; super.setLabel(""); aciertos = false; } } PanelCombate pc; int vert, hori, cant = 0; AccionBoton(PanelCombate p, int v, int h) { pc = p; vert = v; hori = h; } boolean salida = false; if (!pc.tablero[hori][vert].aciertos) { pc.tablero[hori][vert].aciertos = true; pc.disparos++; if (pc.naves[hori][vert]) { pc.tablero[vert][hori].setLabel(""); for (int x = 0; x < 11; x++) { for (int y = 0; y < 11; y++) { if (pc.naves[x][y]) { if (x == hori && y == vert) { pc.tablero[x][y].setLabel(""); pc.aciertos++; } } } } } pc.fallos = disparos - aciertos; if (pc.aciertos >=9){ } if ((pc.disparos >= 6 && pc.aciertos == 0) || (pc.disparos >= 24)) { JOptionPane.showMessageDialog(pc.getParent(), "Obtuviste "+aciertos+" aciertos y " +fallos+ " fallas " + " de un total de " +disparos+ " disparos "); if(JOptionPane.showConfirmDialog(pc.getParent(), "Desea Reiniciar el juego","Aviso", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION){ if(salida != true){ }else{ } } } } } } }