Ejemplo n.º 1
0
  /** Update the current normalImage based on the mouse state */
  private void updateImage() {
    if (!over) {
      currentImage = normalImage;
      currentColor = normalColor;
      state = NORMAL;
      mouseUp = false;
    } else {
      if (mouseDown) {
        if ((state != MOUSE_DOWN) && (mouseUp)) {
          if (mouseDownSound != null) {
            mouseDownSound.play();
          }
          currentImage = mouseDownImage;
          currentColor = mouseDownColor;
          state = MOUSE_DOWN;

          notifyListeners();
          mouseUp = false;
        }
      } else {
        mouseUp = true;
        if (state != MOUSE_OVER) {
          if (mouseOverSound != null) {
            mouseOverSound.play();
          }
          currentImage = mouseOverImage;
          currentColor = mouseOverColor;
          state = MOUSE_OVER;
        }
      }
    }

    mouseDown = false;
    state = NORMAL;
  }
Ejemplo n.º 2
0
  public void collideCheck(Balloon balloon) {
    if (renderlist.size() == 2
        && renderlist.get(0).getX() <= -2120
        && (name.equals("frontground") || name.equals("cavefront"))) {
      if (collider2) {
        balloon.setLives(0); // decrease the lives because they collide*/
        if (balloon.isLockLife()) {
          balloon.setSpeed(-300);
          if (!bubblebounce.playing()) {
            bubblebounce.play(1, 0.8f);
          }
        }
        return;
      }

    } else {
      if (collider) {
        balloon.setLives(0);
        if (balloon.isLockLife()) {
          balloon.setSpeed(-300);
          if (!bubblebounce.playing()) {
            bubblebounce.play(1, 0.8f);
          }
        }
      }
    }
  }
Ejemplo n.º 3
0
  public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {

    if ((startKnopf.isMouseOver())) {
      menüSchriftStart = schriftRot;
      if (Mouse.isButtonDown(0)) {
        knopfGedrueckt.play();
        sbg.enterState(1);
      }
    } else {
      menüSchriftStart = schriftSchwarz;
    }
    if (optionenKnopf.isMouseOver()) {
      menüSchriftOptionen = schriftRot;
      if (Mouse.isButtonDown(0)) {
        knopfGedrueckt.play();
        sbg.enterState(2);
      }
    } else {
      menüSchriftOptionen = schriftSchwarz;
    }
    if (creditsKnopf.isMouseOver()) {
      menüSchriftCredits = schriftRot;
      if (Mouse.isButtonDown(0)) {
        knopfGedrueckt.play();
        sbg.enterState(3);
      }
    } else {
      menüSchriftCredits = schriftSchwarz;
    }
  }
Ejemplo n.º 4
0
 public void keyPressed(int key, char c) {
   switch (key) {
     case Input.KEY_DOWN:
       fx.play();
       selected++;
       if (selected >= options.length) {
         selected = 0;
       }
       break;
     case Input.KEY_UP:
       fx.play();
       selected--;
       if (selected < 0) {
         selected = options.length - 1;
       }
       break;
     case Input.KEY_ENTER:
       switch (selected) {
         case 1:
           try {
             game.getState(prevGameState).init(game.getContainer(), game);
           } catch (SlickException e) {
             e.printStackTrace();
           }
           // Break weggelassen, um case 0 auch auszufuehren
         case 0:
           game.enterState(
               prevGameState,
               new FadeOutTransition(Color.black, 100),
               new FadeInTransition(Color.black, 100));
           break;
         case 2:
           game.enterState(
               MainMenu.stateID,
               new FadeOutTransition(Color.black, 100),
               new FadeInTransition(Color.black));
           break;
       }
       break;
     case Input.KEY_ESCAPE:
     case Input.KEY_P:
       game.enterState(
           prevGameState,
           new FadeOutTransition(Color.black, 100),
           new FadeInTransition(Color.black, 100));
       break;
     default:
       break;
   }
 }
Ejemplo n.º 5
0
 public void advance(int distanceMiles) {
   int lastProgress = progress;
   progress += distanceMiles;
   // The enemy cannot overtake the player's ship
   if (progress > Ship.get().getProgressMiles()) progress = Ship.get().getProgressMiles();
   if (lastProgress < 0 && progress >= 0) alarm.play();
 }
Ejemplo n.º 6
0
  public void jump(float jumpVelocity) throws SlickException {
    super.jump(jumpVelocity);
    jumpSound.play();

    // int rand = (int) (Math.random() * 5) + 1;
    // super.playSound("audio/sfx/g2dp_jump_0" + rand + ".wav");
  }
Ejemplo n.º 7
0
  public void keyPressed(int key, char c) {
    switch (key) {
      case Input.KEY_ENTER:
        bienvenue.stop();
        if (selected == 1) {
          try {
            game.getState(3).init(container, game);
          } catch (SlickException e) {
            e.printStackTrace();
          }
          game.enterState(3);
        } else if (selected == 2) {
          try {
            game.getState(7).init(container, game);
          } catch (SlickException e) {
            e.printStackTrace();
          }
          game.enterState(7);

        } else if (selected == 3) {
          container.exit();
        }
        break;
      case Input.KEY_K:
      case Input.KEY_UP:
        if (this.selected > 1) {
          --this.selected;
        } else this.selected = 3;
        playSound();
        break;
      case Input.KEY_J:
      case Input.KEY_DOWN:
        if (this.selected < 3) {
          ++this.selected;
        } else this.selected = 1;
        playSound();
        break;
      case Input.KEY_F1:
        bienvenue.stop();
        bienvenue.play();
        break;

      case Input.KEY_ESCAPE:
        container.exit();
        break;
    }
  }
Ejemplo n.º 8
0
  @Override
  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    final int X_DECCEL = 2;
    final int Y_ACCEL = 3;

    // Player movement
    Player p = getPlayer();
    if (!p.isAlive()) {
      Sound fx = null;
      if (playDeathSound) {
        fx = new Sound("res/audio/sounds/FallAndSplat.wav");
        fx.play();
        playDeathSound = false;
      }
      while (!fx.playing()) {
        container.exit();
      }
    }
    // Account for input
    Input i = container.getInput();
    if (i.isKeyDown(Input.KEY_D)) {
      p.accelerate(new Vector2f(4, 0));
    }
    if (i.isKeyDown(Input.KEY_A)) {
      p.accelerate(new Vector2f(-4, 0));
    }
    if (i.isKeyPressed(Input.KEY_W)) {
      p.jump();
    }

    Vector2f playerVect = p.getAccelerationVector();
    // Deccelerate X
    if (playerVect.x < 4 && playerVect.x > -4) {
      p.accelerate(new Vector2f(-1 * playerVect.x, 0));
    } else if (playerVect.x >= 4) {
      p.accelerate(new Vector2f(-1 * X_DECCEL, 0));
    } else {
      p.accelerate(new Vector2f(X_DECCEL, 0));
    }

    // Accellerate Y
    p.accelerate(new Vector2f(0, Y_ACCEL));
    p.move();
    this.manageCollision(true, true, true);
  }
Ejemplo n.º 9
0
 public void onFire() {
   System.out.println("Playing sound SOOON");
   if (onFire == null) {
     System.out.println("Its null for " + this.name);
   } else {
     onFire.play();
     System.out.println("Playing");
   }
 }
Ejemplo n.º 10
0
 public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
   this.container = gc;
   this.game = sbg;
   bienvenue = new Sound("ressources/sounds/bienvenue.ogg");
   jouer = new Sound("ressources/sounds/menuJouer.ogg");
   score = new Sound("ressources/sounds/menuScore.ogg");
   quitter = new Sound("ressources/sounds/menuQuitter.ogg");
   bienvenue.play();
 }
Ejemplo n.º 11
0
 @Override
 public void play() {
   if (maximalInstances == 0 || instanceCounter.count() < maximalInstances) {
     if (!preventSimulaniousPlay || (preventSimulaniousPlay && !playing())) {
       super.play();
       instanceCounter.add(playingTime);
     }
   }
 }
Ejemplo n.º 12
0
 public void setFlying(boolean goingToFly) {
   if (goingToFly) {
     spraySound.play();
     this.getBody().setMaxVelocity(500, 500);
     useBeer();
   } else {
     //			rotation = 0;
     this.getBody().setMaxVelocity(100, 500);
   }
   this.flying = goingToFly;
 }
Ejemplo n.º 13
0
  public String getDrawText(Sound typeSound) {
    if (counter >= max) {
      waiting = true;
      return message;
    } else {
      waiting = false;
      fpsCounter++;
      if (typeSound.playing() == false) {
        typeSound.play(1.4f, 0.4f);
      }

      if (fpsCounter % 5 == 0) {
        fpsCounter = 0;
        counter++;
        return message.substring(0, counter);
      } else {
        return message.substring(0, counter);
      }
    }
  }
Ejemplo n.º 14
0
 void stop() {
   SoundStore.get().clear();
   InternalTextureLoader.get().clear();
   if (partido.fueGrabado()) {
     if (JOptionPane.showConfirmDialog(
             principal, "Desea guardar el partido?", "Guardar Partido", JOptionPane.YES_NO_OPTION)
         == 0) {
       if (jfc.showSaveDialog(principal) == JFileChooser.APPROVE_OPTION) {
         try {
           partido.getPartidoGuardado().save(jfc.getSelectedFile());
           if (principal != null) {
             principal.addGuardadoLocal(new File[] {jfc.getSelectedFile()});
           }
         } catch (Exception ex) {
           logger.error("Error al guardar partido", ex);
         }
       }
     }
   }
   if (sonidos) {
     for (Sound s : ambiente) {
       s.stop();
     }
     gol.stop();
     remate[0].stop();
     remate[1].stop();
     poste[0].stop();
     poste[1].stop();
     ovacion[0].stop();
     ovacion[1].stop();
     rebote.stop();
     silbato.stop();
   }
   if (principal != null) {
     principal.setVisible(true);
     principal.requestFocus();
   } else {
     System.exit(0);
   }
 }
Ejemplo n.º 15
0
 public void playSound() {
   jouer.stop();
   score.stop();
   quitter.stop();
   if (!bienvenue.playing()) {
     switch (selected) {
       case 1:
         jouer.play();
         break;
       case 2:
         score.play();
         break;
       case 3:
         quitter.play();
         break;
     }
   }
 }
  @Override
  public void update(GameContainer container, StateBasedGame state, int delta)
      throws SlickException {
    frog.update(container, delta);
    allOtherObjects.update(container, delta);

    // Musik loopen
    if (sound_music.playing() == false) {
      if (isMusicPaused == true) sound_music.resume();
      else sound_music.loop();
    }

    // Testobjekte
    woman.update(container, delta);
    timerBar.update(container, delta);

    // Rupees einsammeln
    for (Rupee obj : allOtherObjects.getRupees()) {
      if (frog.checkCollisionWith(obj) == true) {
        if (obj.getCollected() == false) {
          obj.setCollected(true);
          obj.getSound().play();
          frog.incrRupeesInBag(obj.getWert());
          frog.getRupeeStringHover().activate(frog.getPosX(), frog.getPosY(), obj.getWert());
        }
      }
    }

    // und bei der Frau abgeben!
    /*
     * Nur wenn die Rupees bei der Frau abgegegeben werden
     * dann wird die Zeit vollends aufgefüllt
     */
    /*
     * Berechnung des Highscores:
     * Rupees * verbliebende Zeit = Highscore
     */
    if (frog.checkCollisionWith(woman) == true && frog.getRupeesInBag() != 0) {

      // Highscore Berechnung!
      highscore += (long) ((timerBar.getWidth() / 1) * frog.getRupeeaInBag());

      rupeeCounter += frog.getRupeesInBag();
      frog.setRupeesInBag(0);
      woman.setWithBag(true);
      woman.setCollisionOn(false);
      woman.setAnimation(true);
      woman.getSound().play();
      timerBar.restoreWidth();
      for (Rupee obj : allOtherObjects.getRupees()) {
        obj.randomize();
      }
    }

    // beim Tod/Gameover
    if (frog.getLifeCount() <= 0) {
      frog.getSound_gameover().play();
      sound_music.stop();

      frog.reset();
      frog.setRupeesInBag(0);
      frog.setLifeCount(2);
      timerBar.setTimerOn(false);

      state.enterState(GameStates.GameOver);
    }

    // wenn die Zeit abgelaufen wird: ein Leben nehmen!
    // außerdem die Rupees wieder neu druchwürfeln
    if (timerBar.getEvent() == true) {
      frog.reduceLifeCount();
      frog.incrLifeCount();
      timerBar.setEvent(false);
      frog.reset();
      timerBar.setTimerOn(false);

      for (Rupee obj : allOtherObjects.getRupees()) {
        obj.randomize();
      }
    }

    // Kollisionsabfrage
    // Frosch mit Autos
    for (GameObj obj : allOtherObjects.getCars()) {
      if (frog.checkCollisionWith(obj) == true) {
        frog.reset();
        timerBar.setTimerOn(false);

        for (Rupee obj2 : allOtherObjects.getRupees()) {
          obj2.randomize();
        }
      }
    }

    // mit den LOGS oder dem WASSER
    frog.setOnBoat(false);

    for (GameObj obj : allOtherObjects.getLogs()) {
      if (frog.checkCollisionWith(obj) == true) {
        frog.setOnBoat(true);
      }
    }

    for (GameObj obj : allOtherObjects.getLogs()) {
      if (frog.checkCollisionWith(obj) == true) {
        frog.setPosX(frog.getPosX() + (obj.getSpdX() * (delta / 1000.0f)));
      }
    }

    for (GameObj obj2 : allOtherObjects.getRiver()) {
      if (frog.checkCollisionWith(obj2) == true && frog.getOnBoat() == false) {
        frog.reset();
        timerBar.setTimerOn(false);

        for (Rupee obj : allOtherObjects.getRupees()) {
          obj.randomize();
        }
      }
    }

    // Falls man den Frosch wegen eines resettes nicht mehr steuern kann
    // sollen so und so viele Sekunden passieren bis man ihn wieder
    // kontrollieren kann!
    if (frog.getEingabe() == false) {
      resetTimer--;
    }
    if (resetTimer <= 0) {
      frog.setEingabe(true);
      frog.setCollisionOn(true);
      timerBar.setTimerOn(true);
      resetTimer = RESETTIMER;
      timerBar.restoreWidth();
    }

    // Der Frosch soll nicht durch die Wände können!
    for (GameObj obj : allOtherObjects.getWall()) {
      if (frog.checkCollisionWith(obj) == true) {
        // von rechts
        if (frog.getSpdX() > 0) frog.setPosX(frog.getPrevPosX());
        // von links
        else if (frog.getSpdX() < 0) frog.setPosX(frog.getPrevPosX());
        // von unten
        if (frog.getSpdY() < 0 && frog.getPosY() >= 82) frog.setPosY(frog.getPrevPosY());
      }
    }

    // Pause game
    Input input = container.getInput();
    if (input.isKeyPressed(Input.KEY_ESCAPE)) {
      sound_pause.play();
      sound_music.pause();
      isMusicPaused = true;
      state.enterState(GameStates.Paused);
    }

    /*
     * Der Guide wird nur ganz am Anfang oben als kleiner Text eingeblendet.
     * Sobald einmal die Rupees bei der Frau abgegeben worden sind,
     * verschwindet der Text bzw ein motivierender Text steht dort.
     */

    if (guideString.equals(Constants.GUIDE5) == false) {
      // erster Tipp
      guideString = Constants.GUIDE1;

      // zweiter Tipp
      if (frog.getRupeesInBag() >= 2) guideString = Constants.GUIDE2;

      // dritter Tipp
      if (rupeeCounter >= 1) guideString = Constants.GUIDE3;

      // vierter Tipp
      if (guideString.equals(Constants.GUIDE3) && frog.getRupeesInBag() >= 1)
        guideString = Constants.GUIDE4;

      // Ende
      if (guideString.equals(Constants.GUIDE4) && frog.getRupeesInBag() == 0)
        guideString = Constants.GUIDE5;
    }
  }
Ejemplo n.º 17
0
  /**
   * Play a sound effect.
   *
   * @param sound The location of the sound effect to play.
   * @throws SlickException
   */
  public void playSound(String sound) throws SlickException {
    if (!soundOn) return;

    sfx = new Sound(sound);
    sfx.play();
  }
Ejemplo n.º 18
0
 @Override
 public void stop() {
   super.stop();
   instanceCounter.clear();
 }
Ejemplo n.º 19
0
  public SoundManager(Resources resources) {
    this.resources = resources;

    Sound fx = resources.getSound(SoundName.Theme);
    fx.play(1.0f, 1.0f);
  }
Ejemplo n.º 20
0
  /**
   * Loop a sound.
   *
   * @param sound The location of the sound to loop.
   * @throws SlickException
   */
  public void loopSound(String sound) throws SlickException {
    if (!soundOn) return;

    music = new Sound(sound);
    music.loop();
  }
Ejemplo n.º 21
0
 /** Turn off the sound. Calls Sound.stop() on the sfx and music. */
 public void muteSound() {
   // Yes, stop the sound entirely, not just mute it.
   sfx.stop();
   music.stop();
 }
Ejemplo n.º 22
0
 /**
  * The sound belonging to the shots fired.
  *
  * @throws SlickException possible Exception.
  */
 public void laserSound() throws SlickException {
   Sound laser = new Sound("sound/shoot.wav");
   laser.play();
 }
Ejemplo n.º 23
0
  /** @see org.newdawn.slick.BasicGame#keyPressed(int, char) */
  public void keyPressed(int key, char c) {
    if (key == Input.KEY_ESCAPE) {
      System.exit(0);
    }
    if (key == Input.KEY_SPACE) {
      sound.play();
    }
    if (key == Input.KEY_B) {
      burp.play();
    }
    if (key == Input.KEY_A) {
      sound.playAt(-1, 0, 0);
    }
    if (key == Input.KEY_L) {
      sound.playAt(1, 0, 0);
    }
    if (key == Input.KEY_RETURN) {
      charlie.play(1.0f, 1.0f);
    }
    if (key == Input.KEY_P) {
      if (music.playing()) {
        music.pause();
      } else {
        music.resume();
      }
    }
    if (key == Input.KEY_C) {
      music.stop();
      if (music == musica) {
        music = musicb;
      } else {
        music = musica;
      }

      music.loop();
    }
    if (key == Input.KEY_E) {
      if (engine.playing()) {
        engine.stop();
      } else {
        engine.loop();
      }
    }

    if (c == '+') {
      volume += 1;
      setVolume();
    }

    if (c == '-') {
      volume -= 1;
      setVolume();
    }

    if (key == Input.KEY_Y) {
      int vol = (int) (music.getVolume() * 10);
      vol--;
      if (vol < 0) vol = 0;
      // set individual volume of music
      music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_X) {
      int vol = (int) (music.getVolume() * 10);
      vol++;
      if (vol > 10) vol = 10;
      // set individual volume of music
      music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_N) {
      int vol = (int) (myContainer.getSoundVolume() * 10);
      vol--;
      if (vol < 0) vol = 0;
      // set global volume of sound fx
      myContainer.setSoundVolume(vol / 10.0f);
    }
    if (key == Input.KEY_M) {
      int vol = (int) (myContainer.getSoundVolume() * 10);
      vol++;
      if (vol > 10) vol = 10;
      // set global volume of sound fx
      myContainer.setSoundVolume(vol / 10.0f);
    }
  }
Ejemplo n.º 24
0
  /** Actualiza el juego, uso interno */
  @Override
  public void update(GameContainer gc, int fps) throws SlickException {
    Input i = gc.getInput();
    if (guardado && progreso) {
      if (i.isMouseButtonDown(0)) {
        double y =
            1 - (double) (Math.max(20, Math.min(i.getMouseY(), sy - 20)) - 20) / (double) (sy - 40);
        PartidoGuardado pguardado = (PartidoGuardado) partido;
        pguardado.setTiempo((int) (y * (double) pguardado.getIterciones()));
      }
    }
    if (i.isKeyDown(Input.KEY_SUBTRACT)) {
      escala = escala * 0.970;
    } else if (i.isKeyDown(Input.KEY_ADD)) {
      escala = escala / 0.970;
    }
    if (i.isKeyPressed(Input.KEY_F1)) {
      estadio = !estadio;
    }
    if (i.isKeyPressed(Input.KEY_F2)) {
      entorno = !entorno;
    }
    if (i.isKeyPressed(Input.KEY_F3)) {
      showfps = !showfps;
      gc.setShowFPS(showfps);
    }
    if (i.isKeyPressed(Input.KEY_F4)) {
      tipoTexto = (tipoTexto + 1) % 5;
    }
    if (i.isKeyPressed(Input.KEY_F5)) {
      marcador = !marcador;
    }
    if (i.isKeyDown(Input.KEY_ESCAPE)) {
      gc.setSoundVolume(0);
      gc.setSoundOn(false);
      stop();
      gc.exit();
    }
    if (i.isKeyDown(Input.KEY_P)) {
      pause = !pause;
      if (pause) {
        gc.pause();
      } else {
        gc.resume();
      }
    }
    if (guardado && i.isKeyPressed(Input.KEY_LEFT)) {
      if (incremento == 0) {
        incremento = -1;
      } else if (incremento == -1) {
        incremento = -2;
      } else if (incremento == -2) {
        incremento = -4;
      } else if (incremento == -4) {
        incremento = -4;
      } else if (incremento == 1) {
        incremento = 0;
      } else if (incremento == 2) {
        incremento = 1;
      } else if (incremento == 4) {
        incremento = 2;
      }
      iteracionControl = 30;
    }
    if (guardado && i.isKeyPressed(Input.KEY_RIGHT)) {
      if (incremento == 0) {
        incremento = 1;
      } else if (incremento == 1) {
        incremento = 2;
      } else if (incremento == 2) {
        incremento = 4;
      } else if (incremento == 4) {
        incremento = 4;
      } else if (incremento == -1) {
        incremento = 0;
      } else if (incremento == -2) {
        incremento = -1;
      } else if (incremento == -4) {
        incremento = -2;
      }
      iteracionControl = 30;
    }
    paso = 0;
    if (guardado && i.isKeyPressed(Input.KEY_UP)) {
      incremento = 0;
      paso = 1;
    }
    if (guardado && i.isKeyPressed(Input.KEY_DOWN)) {
      incremento = 0;
      paso = -1;
    }
    if (guardado && i.isKeyPressed(Input.KEY_HOME)) {
      inicio = pg.getTiempo();
    }
    if (guardado && i.isKeyPressed(Input.KEY_END)) {
      fin = pg.getTiempo();
    }
    if (guardado && i.isKeyPressed(Input.KEY_DELETE)) {
      if (JOptionPane.showConfirmDialog(
              null,
              "Desea eliminar los frames seleccionados?",
              "Eliminar Frames",
              JOptionPane.YES_NO_OPTION)
          == 0) {
        if (inicio < fin) {
          pg.delete(inicio, fin);
          fin = inicio;
        } else {
          pg.delete(inicio, pg.getIterciones() - 1);
          pg.delete(0, fin);
          inicio = 0;
          fin = pg.getIterciones() - 1;
          pg.setTiempo(0);
        }
      }
    }
    if (guardado && i.isKeyPressed(Input.KEY_S)) {
      if (JOptionPane.showConfirmDialog(
              null, "Desea gardar el partido?", "Guardar Partido", JOptionPane.YES_NO_OPTION)
          == 0) {
        // System.out.println(pg.getURL().getProtocol());
        if (jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
          try {
            pg.save(jfc.getSelectedFile());
          } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error al guardar partido...");
            if (principal != null) {
              try {
                principal.addGuardadoLocal(new File[] {jfc.getSelectedFile()});
              } catch (Exception ex) {
              }
            }
          }
        }
      }
    }
    if (iteracionControl > 0) {
      iteracionControl--;
    }

    vx = (partido.getPosiciones()[2][0].getX() - px) / Constants.SEGUIMIENTO_CAMARA;
    vy = (partido.getPosiciones()[2][0].getY() - py) / Constants.SEGUIMIENTO_CAMARA;

    px = px + vx;
    py = py + vy;

    for (int j = 0; j < 11; j++) {
      posPrev[j][0] = posActu[0][j];
      posPrev[j][1] = posActu[1][j];
    }

    if (partido != null) {
      if (guardado) {
        try {
          pg.setTiempo(pg.getTiempo() + incremento + paso);
        } catch (Exception ex) {
          logger.error("Error al establecer tiempo de partido guardo", ex);
          throw new SlickException(ex.getLocalizedMessage());
        }
      } else {
        try {
          partido.iterar();
        } catch (Exception ex) {
          logger.error("Error al iterar partido", ex);
          throw new SlickException(ex.getLocalizedMessage());
        }
      }

      boolean oldSound = sonidos;
      if (guardado && incremento == 0) {
        sonidos = false;
      }

      if (audioAmbiente == audioAmbienteIdx) {
        if (sonidos) {
          ambiente[audioIdx].play(pinch(), volumenAmbiente);
        }
        audioAmbiente = 50 + rand.nextInt(20);
        audioAmbienteIdx = 0;
        audioIdx = rand.nextInt(ambiente.length);
      }
      audioAmbienteIdx++;

      if (partido.estanSilbando()) {
        if (sonidos) {
          silbato.play(pinch(), volumenCancha);
        }
      }
      if (partido.estanRematando()) {
        if (sonidos) {
          remate[rand.nextInt(2)].play(pinch(), volumenCancha);
        }
      }
      if (partido.estanOvacionando()) {
        if (sonidos) {
          ovacion[rand.nextInt(2)].play(pinch(), volumenAmbiente);
        }
      }
      if (partido.esGol()) {
        if (sonidos) {
          gol.play(pinch(), volumenAmbiente);
        }
        golIter = 1;
      }

      if (golIter > 0) {
        golIter++;
        if (golIter == 50) {
          golIter = 0;
        }
      }

      if (partido.isLibreIndirecto()) {
        if (sonidos) {
          silbato.play(pinch(), volumenAmbiente);
        }
      }

      if (partido.isOffSide()) offSideIter = 1;

      if (offSideIter > 0) {
        offSideIter += dxsaque;
        if (offSideIter > 800) {
          offSideIter = 0;
        }
      }

      if (partido.cambioDeSaque()) {
        if (sonidos) {
          silbato.play(pinch(), volumenAmbiente);
        }
        saqueIter = 1;
      }

      if (saqueIter > 0) {
        saqueIter = saqueIter + dxsaque;
        if (saqueIter > sx + 2 * 177) {
          saqueIter = 0;
        }
      }
      if (partido.estaRebotando()) {
        if (sonidos) {
          rebote.play(pinch(), volumenCancha);
        }
      }
      if (partido.esPoste()) {
        if (sonidos) {
          poste[rand.nextInt(2)].play(pinch(), volumenCancha);
          ovacion[rand.nextInt(2)].play(pinch(), volumenAmbiente);
        }
      }
      sonidos = oldSound;
      if (partido.estanSacando()) {
        iterSaca = (iterSaca + 1) % 6;
      }
    }

    posActu = partido.getPosiciones();
    for (int j = 0; j < 11; j++) {
      dx = posPrev[j][0].getX() - posActu[0][j].getX();
      dy = posPrev[j][0].getY() - posActu[0][j].getY();
      if (dy != 0 || dx != 0) {
        iteraciones[j][0] = iteraciones[j][0] + 1;
        angulos[j][0] = posPrev[j][0].angle(posActu[0][j]) * 180 / Math.PI + 90;
        if (incremento < 0) {
          angulos[j][0] = angulos[j][0] + 180;
        }
      } else {
        iteraciones[j][0] = 3;
      }

      dx = posPrev[j][1].getX() - posActu[1][j].getX();
      dy = posPrev[j][1].getY() - posActu[1][j].getY();
      if (dy != 0 || dx != 0) {
        iteraciones[j][1] = iteraciones[j][1] + 1;
        angulos[j][1] = posPrev[j][1].angle(posActu[1][j]) * 180 / Math.PI + 90;
        if (incremento < 0) {
          angulos[j][1] = angulos[j][1] + 180;
        }
      } else {
        iteraciones[j][1] = 3;
      }
    }

    for (int j = 1; j < angulosAnteriores[0][0].length; j++) {
      for (int x = 0; x < 11; x++) {
        for (int y = 0; y < 2; y++) {
          angulosAnteriores[x][y][j - 1] = angulosAnteriores[x][y][j];
        }
      }
    }
    for (int x = 0; x < 11; x++) {
      for (int y = 0; y < 2; y++) {
        angulosAnteriores[x][y][angulosAnteriores[0][0].length - 1] = angulos[x][y];
      }
    }
    boolean ok = true;
    for (int x = 0; x < 11; x++) {
      for (int y = 0; y < 2; y++) {
        angVisible[x][y] = 0;
        for (int j = 0; j < angulosAnteriores[0][0].length; j++) {
          angVisible[x][y] = angVisible[x][y] + angulosAnteriores[x][y][j];
        }
        angVisible[x][y] = angVisible[x][y] / (double) angulosAnteriores[0][0].length;
      }
    }

    if (autoescala) {
      int[] escalas =
          (Transforma.transform(
              partido.getPosVisibleBalon(),
              Constants.centroCampoJuego,
              -Transforma.transform(px, escala),
              -Transforma.transform(py, escala),
              escala));
      escalaAjustada =
          escala
              * Math.min(
                  0.7d * sx2 / (double) Math.abs(escalas[0]),
                  0.7d * sy2 / (double) Math.abs(escalas[1]));
    }
    if (!noAutoEscalar && partido.esGol()) {
      noAutoEscalar = true;
    }
    if (noAutoEscalar && partido.estanRematando()) {
      noAutoEscalar = false;
    }
  }