Exemple #1
0
 /** El metodo actualizar se encarga del manejo del teclado y de movimiento de las imagenes */
 public void actualizar() {
   if (fondo1 != null) {
     fondo1.mover(10);
     fondo2.mover(10);
     fondo3.mover(10);
     fondo4.mover(10);
     puntajes.mover(1);
     ayuda.mover(1);
     creditos.mover(1);
     salir.mover(1);
     titulo.mover(1);
     menuPuntajes = null;
     menuAyuda = null;
     menuCreditos = null;
     menuSalir = null;
     menuInicio = null;
   }
   if (menuPuntajes != null) {
     try {
       menuPuntajes.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (menuAyuda != null) {
     try {
       menuAyuda.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (menuCreditos != null) {
     try {
       menuCreditos.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (menuSalir != null) {
     try {
       menuSalir.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     if (menuSalir.getSalir()) {
       midlet.terminar();
       animador.terminar();
       midlet.detenerMusica();
       terminar = true;
     }
   }
   if (menuInicio != null) {
     try {
       menuInicio.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (highLight != null) {
     int estado = getKeyStates();
     if (estado == 0) {
       bandera = false;
     }
     if (highLight.getPrioridad() == juego.getPrioridad()) {
       if ((estado & UP_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(puntajes.getX() - 1, puntajes.getY() - 1);
         highLight.setPrioridad(puntajes.getPrioridad());
         bandera = true;
       }
       if ((estado & DOWN_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(salir.getX(), salir.getY());
         highLight.setPrioridad(salir.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0 && !bandera) {
         menuInicio = new Inicio(this);
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == creditos.getPrioridad()) {
       if ((estado & UP_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & LEFT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(salir.getX(), salir.getY());
         highLight.setPrioridad(salir.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         menuCreditos = new Creditos(this);
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == puntajes.getPrioridad()) {
       if ((estado & RIGHT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(ayuda.getX(), ayuda.getY());
         highLight.setPrioridad(ayuda.getPrioridad());
         bandera = true;
       }
       if ((estado & DOWN_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         try {
           menuPuntajes = new Puntajes(this, lecturaScores());
         } catch (IOException ex) {
           menuPuntajes = new Puntajes(this, "0");
         }
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == salir.getPrioridad()) {
       if ((estado & RIGHT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(creditos.getX(), creditos.getY());
         highLight.setPrioridad(creditos.getPrioridad());
         bandera = true;
       }
       if ((estado & UP_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         menuSalir = new Salir(this);
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == ayuda.getPrioridad()) {
       if ((estado & LEFT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(puntajes.getX(), puntajes.getY());
         highLight.setPrioridad(puntajes.getPrioridad());
         bandera = true;
       }
       if ((estado & DOWN_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         menuAyuda = new Ayuda(this);
         borrarTodo();
         bandera = true;
       }
     }
   }
 }
Exemple #2
0
  /** Este metodo te permite dibujar todas las opciones del menu asi como los respectivos fondos. */
  public void dibujar() {
    if (logoTec != null) {
      dibujarLogoTec();
    }
    logoTec = null;
    if (fondo4 != null) {
      fondo1.dibujar(g);
      fondo2.dibujar(g);
      fondo3.dibujar(g);
      fondo4.dibujar(g);
      if (fondo4.getY() >= 108) {
        puntajes.dibujar(g);
        if (highLight.getPrioridad() == puntajes.getPrioridad()) {
          tituloPuntajes.dibujar(g);
        }

        ayuda.dibujar(g);
        if (highLight.getPrioridad() == ayuda.getPrioridad()) {
          tituloAyuda.dibujar(g);
        }

        creditos.dibujar(g);
        if (highLight.getPrioridad() == creditos.getPrioridad()) {
          tituloCreditos.dibujar(g);
        }

        salir.dibujar(g);
        if (highLight.getPrioridad() == salir.getPrioridad()) {
          tituloSalir.dibujar(g);
        }

        juego.dibujar(g);
        if (puntajes.getX() <= 20) {
          if (highLight.getPrioridad() == juego.getPrioridad()) {
            tituloJuego1.dibujar(g);
            tituloJuego2.dibujar(g);
            tituloJuego3.dibujar(g);
            tituloJuego4.dibujar(g);
          }
        }

        highLight.dibujar(g);
        titulo.dibujar(g);
      }
    }

    if (menuPuntajes != null) {
      menuPuntajes.g = this.getGraphics();
      menuPuntajes.dibujar();
    }

    if (menuAyuda != null) {
      menuAyuda.g = this.getGraphics();
      menuAyuda.dibujar();
    }

    if (menuCreditos != null) {
      menuCreditos.g = this.getGraphics();
      menuCreditos.dibujar();
    }

    if (menuSalir != null) {
      menuSalir.g = this.getGraphics();
      menuSalir.dibujar();
    }

    if (menuInicio != null) {
      menuInicio.g = this.getGraphics();
      menuInicio.dibujar();
    }

    flushGraphics();
  }