コード例 #1
0
ファイル: Menu.java プロジェクト: 6xhhs/biolipsis
 /**
  * Cambia la bandera para iniciar el juego
  *
  * @param inicioJuego
  */
 public void setInicioJuego(boolean inicioJuego) {
   this.inicioJuego = inicioJuego;
   if (this.inicioJuego) {
     animador.terminar();
     cambio = true;
   }
 }
コード例 #2
0
ファイル: Menu.java プロジェクト: 6xhhs/biolipsis
 /**
  * @param midlet Esto te permite poder correr en el midlet el menu
  * @throws Exception Esta excepcion te permite detectar si una imagen no se cargo.
  */
 public Menu(Biolipsis midlet) throws Exception {
   super(true);
   this.midlet = midlet;
   g = this.getGraphics();
   setFullScreenMode(true);
   bandera = false;
   terminar = false;
   cambio = false;
   seleccionPersonaje = false;
   inicioJuego = false;
   nivel = 1;
   highscores = 0;
   menuInicio = null;
   menuAyuda = null;
   menuCreditos = null;
   menuPuntajes = null;
   menuSalir = null;
   crearImagenes();
   try {
     logoTec = new Imagenes("/logoTec.jpg", 0, 0, 60);
   } catch (IOException e) {
     System.out.println("");
     e.printStackTrace();
   }
   animador = new AnimadorJuego(this);
   animador.iniciar();
 }
コード例 #3
0
ファイル: Menu.java プロジェクト: 6xhhs/biolipsis
 /** 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;
       }
     }
   }
 }