/*
   * cambia la dificultad cada cierto tiempo (maximo nivel = 5)
   */
  public int cambioDific() {
    // System.out.println(time.millisElapsed());

    if (time.millisElapsed() >= 30000 && nivelActual == 1) {
      varDific = 250;
      contLV.setValue(2);
      nivelActual = 2;
      velExtra = 1;
    } else if (time.millisElapsed() >= 50000 && nivelActual == 2) {
      varDific = 100;
      contLV.setValue(3);
      nivelActual = 3;
      velExtra = 2;
    } else if (time.millisElapsed() >= 100000 && nivelActual == 3) {
      varDific = 70;
      contLV.setValue(4);
      nivelActual = 4;
      // velExtra=2;
    } else if (time.millisElapsed() >= 150000 && nivelActual == 4) {
      varDific = 50;
      contLV.setValue(5);
      nivelActual = 5;
      if (velExtra < 3) velExtra = 3;
    }
    return (varDific);
  }
  /*
   * crea los contadores, mensajes, personaje y tiempos del juego
   */
  public void creanivel() {
    time = new SimpleTimer();
    time.mark();
    Barr = new Barra();
    sound2.stop();
    bandBarra = 0;
    varDific = 450;
    nivelActual = 1;
    velExtra = 0;

    orbPj = new Orb();
    addObject(orbPj, 390, 463);

    addObject(new Mensaje("Nivel"), 623, 93);
    addObject(new Mensaje("Vida"), 623, 151);
    addObject(new Mensaje("Tiempo"), 623, 31);
    addObject(new Mensaje("Color seleccionado"), 687, 439);

    contLV = new Counter();
    addObject(contLV, 686, 92);
    contLV.setValue(1);

    contHP = new Counter();
    addObject(contHP, 686, 150);
    contHP.setValue(orbPj.getHP());

    contTime = new Counter();
    addObject(contTime, 686, 30);

    muestraColor = new acColor();
    addObject(muestraColor, 691, 497);

    sound.playLoop();
  }
  /*
   * espera que se precione un boton, controla el juego; las barras objetos, dificultado y
   * el game over
   */
  public void act() {
    if (opcion == 0) {
      leeboton();
    }

    if (opcion == 1) {
      tiempo();
      agregaBarra();
      agregaObjetos();

      cambioDific();
      muestraColor.cambia(orbPj.getColAct());

      if (orbPj.getGameOver() == 1) {
        opcion = 2;
        sound.stop();
        record = tiempoActual;
        eliminaObjetos();
        setBackground("gameover.png");
        addObject(new Mensaje("ATRAS"), 710, 27);
        bot5 = new boton();
        addObject(bot5, 716, 31);

        addObject(new Mensaje("PUNTUACION"), 400, 458);
        total = new Counter();
        addObject(total, 401, 502);
        total.setValue(record);

        actualizaRecord();
      }

      // System.out.println(orbPj.getGameOver());
    }

    if (opcion == 2) {
      if (Greenfoot.mouseClicked(bot5)) {
        eliminaObjetos();
        opcion = 0;
        sound2.playLoop();
        menu();
      }
    }

    if (opcion == 3) {

      if (Greenfoot.mouseClicked(bot5)) {

        opcion = 2;
        // menu();

      }
    }
  }
예제 #4
0
 void renderCounters(Graphics2D g) {
   Counter.renderCounters(counters, counterStyle, g);
 }
 /*
  * cuenta el tiempo se juego en segundos
  */
 public void tiempo() {
   tiempoActual = time.millisElapsed() / 1000;
   contTime.setValue(tiempoActual);
 }