/** * checks and sets the state of this button. * * @param input the current input * @param butPosX the X position of this button * @param butPosY the Y position of this button * @param butWidth the width of this button * @param butHeight the height of this button */ protected void buttonStateCheck( Input input, int butPosX, int butPosY, int butWidth, int butHeight) { if (contains( input.getMouseX(), input.getMouseY(), butPosX, butPosY, butPosX + butWidth, butPosY + butHeight)) { if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && (getState() == STATE_HOVER || getState() == STATE_PRESSED)) { setState(STATE_PRESSED); setClicked(true); } else { if (!input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { setState(STATE_HOVER); } else { setState(STATE_IDLE); } } } else if (!(input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && getState() == STATE_PRESSED)) { setState(STATE_IDLE); setClicked(false); } }
@Override public void update(GameContainer gc, StateBasedGame sb, int delta) throws SlickException { Input input = gc.getInput(); if (input.isMouseButtonDown(0) && bib.spriteCollisionByPoint(input.getAbsoluteMouseX(), input.getAbsoluteMouseY())) sb.enterState(Main.TRACKSCREEN); if (input.isMouseButtonDown(0) && shoes.spriteCollisionByPoint(input.getAbsoluteMouseX(), input.getAbsoluteMouseY())) sb.enterState(Main.TRAININGSCREEN); if (input.isKeyDown(Input.KEY_ESCAPE)) { PauseScreen.screen = 3; sb.enterState(Main.PAUSESCREEN); } } // end update
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { Input input = container.getInput(); int mouseX = input.getMouseX(); int mouseY = input.getMouseY(); boolean startGame = false; boolean exitGame = false; if ((mouseX >= menuX && mouseX <= menuX + startGameOption.getWidth()) && (mouseY >= menuY && mouseY <= menuY + startGameOption.getHeight())) { startGame = true; } else if ((mouseX >= menuX && mouseX <= menuX + exitOption.getWidth()) && (mouseY >= menuY + 100 && mouseY <= menuY + 100 + exitOption.getHeight())) { exitGame = true; } if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { if (startGame) { game.enterState(RunGame.GAMEPLAYSTATE); } else if (exitGame) { container.exit(); } } }
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); if (Mouse.getX() > 89 && Mouse.getX() < 276 && Mouse.getY() > 15 && Mouse.getY() < 69) { Instructions = new Image("res/InstructionsMenu.png"); if (input.isMouseButtonDown(0)) { sbg.enterState(0); } } else { Instructions = new Image("res/Instructions.png"); } }
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { // TODO Auto-generated method stub Input input = container.getInput(); int mouseX = input.getMouseX(); int mouseY = input.getMouseY(); boolean inMenu = false; if (mouseX > 400 && mouseX < 626 && mouseY > 200 && mouseY < 276) inMenu = true; if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && inMenu) { Constant.LEVEL = 0; game.enterState(3); } }
@Override public void poll(Input input, float secounds) { if (selected == this || selected == null) { Vector mousePos = this.getEditor().translateMousePos(input.getMouseX(), input.getMouseY()); if (this.wasInCircle) { this.changePosition(mousePos); } if ((this.shape.isPointIn(mousePos) || this.wasInCircle) && input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { this.wasInCircle = true; selected = this; } else { this.wasInCircle = false; selected = null; } } }
/** * Create a new mouse over area * * @param container The container displaying the mouse over area * @param image The normalImage to display * @param shape The shape defining the area of the mouse sensitive zone */ public MouseOverArea(GUIContext container, Image image, Shape shape) { super(container); area = shape; normalImage = image; currentImage = image; mouseOverImage = image; mouseDownImage = image; currentColor = normalColor; state = NORMAL; Input input = container.getInput(); over = area.contains(input.getMouseX(), input.getMouseY()); mouseDown = input.isMouseButtonDown(0); updateImage(); }
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); int mouseX = input.getMouseX(); int mouseY = input.getMouseY(); System.out.println("PAUSED"); if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { sbg.enterState(SimpleGame.GAMEPLAYSTATE); // GameplayState.currentState = STATES.START_GAME_STATE; // GameplayState.music.loop(1f,.3f); // GameplayState.needReset = true; // GameplayState.playing = false; // GameplayState.health = 100; } if (input.isKeyPressed(Input.KEY_ESCAPE)) { // gc.exit(); } }
public void check(GameContainer gc, int delta) { int x = this.x * width; int y = this.y * height; Input input = gc.getInput(); int mx = input.getMouseX(); int my = input.getMouseY(); // On Hover if ((mx > ox + x && mx < ox + x + width) && (my > oy + y && my < oy + y + height)) { if (!in) { onHover(); in = true; } } else if (in == true) { in = false; onLeave(); } // On Click if ((mx > ox + x && mx < ox + x + width) && (my > oy + y && my < oy + y + height)) { if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && !clicked) { onClick(Input.MOUSE_LEFT_BUTTON, gc); currentButton = Input.MOUSE_LEFT_BUTTON; clicked = true; } else if (input.isMouseButtonDown(Input.MOUSE_MIDDLE_BUTTON) && !clicked) { onClick(Input.MOUSE_MIDDLE_BUTTON, gc); currentButton = Input.MOUSE_MIDDLE_BUTTON; clicked = true; } else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON) && !clicked) { onClick(Input.MOUSE_RIGHT_BUTTON, gc); currentButton = Input.MOUSE_RIGHT_BUTTON; clicked = true; } else if (clicked == true && !input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && !input.isMouseButtonDown(Input.MOUSE_MIDDLE_BUTTON) && !input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) { onRelease(currentButton, gc); clicked = false; } } update(gc, delta); }
@Override public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) throws SlickException { Input in = gameContainer.getInput(); if (in.isKeyPressed(Input.KEY_C)) { clear(); } gameContainer.setMaximumLogicUpdateInterval(updateInterval); if (in.isMousePressed(Input.MOUSE_LEFT_BUTTON)) { float x1 = in.getMouseX() / ratio; float y1 = in.getMouseY() / ratio; if (start == null) { start = new Cell((int) x1, (int) y1, ratio, false); start.start = true; cells[start.gridPosX][start.gridPosY].start = true; cellStack.add(cells[start.gridPosX][start.gridPosY]); } else if (goal == null) { goal = new Cell((int) x1, (int) y1, ratio, false); cells[goal.gridPosX][goal.gridPosY].goal = true; } else { changeCellAtPosition((int) x1, (int) y1); } if (start != null && goal != null) { this.wall = cells[(int) x1][(int) y1].wall; } } if (in.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { if (start != null && goal != null) { mousePressing = true; float x1 = in.getMouseX() / ratio; float y1 = in.getMouseY() / ratio; cells[(int) x1][(int) y1].wall = this.wall; } } else { mousePressing = false; } if (in.isKeyPressed(Input.KEY_ENTER)) { if (mazeSolved && displayingMaze) { clear(); createGraph(); maze = true; } else if (!maze) { this.search = true; } } if (in.isKeyPressed(Input.KEY_M) && !maze) { createGraph(); maze = true; this.logger.initWriter(); } if (in.isKeyPressed(Input.KEY_S)) { clear(); for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells.length; j++) { Random random = new Random(); if (random.nextInt(3) == 0) { cells[i][j].wall = true; } } } setDefaultStartAndEnd(true); } if (in.isKeyPressed(Input.KEY_ADD)) { if (updateInterval > 1) { updateInterval -= 1; } } if (in.isKeyPressed(Input.KEY_SUBTRACT)) { if (updateInterval < 20) { updateInterval += 1; } } if (in.isKeyPressed(Input.KEY_P)) { if (!gameContainer.isPaused()) { gameContainer.pause(); } else { gameContainer.resume(); } } if (in.isKeyPressed(Input.KEY_D)) { this.diagonal = !this.diagonal; } if (in.isKeyPressed(Input.KEY_ESCAPE)) { stateBasedGame.enterState(1); } if (in.isKeyPressed(Input.KEY_A)) { AnalyzeLog.analyzeBacktracks(AnalyzeLog.FIRST); } if (in.isKeyPressed(Input.KEY_I)) { this.createImage(); } if (this.search) { if (start == null || goal == null) { this.search = false; } else { if (ButtonStates.DFSState) { if (solvingVisited.size() < 1) { solvingVisited.add(cells[start.gridPosX][start.gridPosY]); cells[start.gridPosX][start.gridPosY].solvingVisited = true; currentDFSCell = cells[start.gridPosX][start.gridPosY]; } else { for (int x = 0; x < CELLS; x++) { for (int y = 0; y < CELLS; y++) { cells[x][y].dfsCheckNeighbors(); } } if (currentDFSCell.goal) { this.search = false; this.drawWay = true; this.end = currentDFSCell; getPath(false, null); if (displayingMaze) { mazeSolved = true; } foundSolution = true; } else { if (solvingVisited.size() != (CELLS * CELLS)) { ArrayList<Cell> currentNeighbors = new ArrayList<>(); if (currentDFSCell.dfsNorth != null && !currentDFSCell.dfsNorth.solvingVisited && !currentDFSCell.dfsNorth.wall) { currentNeighbors.add(currentDFSCell.dfsNorth); } else if (currentDFSCell.dfsEast != null && !currentDFSCell.dfsEast.solvingVisited && !currentDFSCell.dfsEast.wall) { currentNeighbors.add(currentDFSCell.dfsEast); } else if (currentDFSCell.dfsSouth != null && !currentDFSCell.dfsSouth.solvingVisited && !currentDFSCell.dfsSouth.wall) { currentNeighbors.add(currentDFSCell.dfsSouth); } else if (currentDFSCell.dfsWest != null && !currentDFSCell.dfsWest.solvingVisited && !currentDFSCell.dfsWest.wall) { currentNeighbors.add(currentDFSCell.dfsWest); } else {; } if (currentNeighbors.size() > 0) { Cell neighbor = currentNeighbors.get(0); neighbor.solvingPrevious = currentDFSCell; neighbor.solvingVisited = true; currentDFSCell = neighbor; } else { dfsBacktracked.add(currentDFSCell); dfsBacktracked.add(currentDFSCell.solvingPrevious); currentDFSCell = currentDFSCell.solvingPrevious; } } } } } else if (ButtonStates.AStarState) { } else if (ButtonStates.BFSState) { if (solvingVisited.size() < 1) { solvingVisited.add(cells[start.gridPosX][start.gridPosY]); cells[start.gridPosX][start.gridPosY].solvingVisited = true; cellStack.add(cells[start.gridPosX][start.gridPosY]); } else { if (!cellStack.isEmpty()) { Cell current = (Cell) cellStack.remove(); Cell child; if (current.goal) { this.end = current; this.drawWay = true; this.search = false; getPath(false, null); if (displayingMaze) { mazeSolved = true; } foundSolution = true; } else { while ((child = getUnvisitedChildCell(current)) != null) { child.solvingVisited = true; child.solvingPrevious = current; solvingVisited.add(child); cellStack.add(child); current.solvingCheckNeighbors(diagonal); getPath(true, child); } } } } } else { try { throw new NoSolvingAlgorithmSelectedException(); } catch (Exception e) { e.printStackTrace(); } } } } if (this.maze) { if (this.logger.used) { this.logger.createNewLogFile(); this.logger.initWriter(); this.logger.used = false; } if (cells.length != 0) { logger.writeInLog("Checking neighbors"); for (int i = 0; i < CELLS; i++) { for (int j = 0; j < CELLS; j++) { cells[i][j].genCheckNeighbors(); } } if (genVisited.size() < 1) { genVisited.add(cells[1][1]); currentGenCell = cells[1][1]; currentGenCell.genVisited = true; logger.writeInLog("Adding Cell X1 and Y1 to visited Cells"); } if (genVisited.size() != totalCells) { ArrayList<Cell> currentNeighbors = new ArrayList<>(); if (currentGenCell.north != null && !currentGenCell.north.genVisited && currentGenCell.north.allWallsIntact) { currentNeighbors.add(currentGenCell.north); logger.writeInLog( "Adding north cell to neighbors at: " + currentGenCell.north.gridPosX + "; " + currentGenCell.north.gridPosY); } if (currentGenCell.east != null && !currentGenCell.east.genVisited && currentGenCell.east.allWallsIntact) { currentNeighbors.add(currentGenCell.east); logger.writeInLog( "Adding east cell to neighbors at: " + currentGenCell.east.gridPosX + "; " + currentGenCell.east.gridPosY); } if (currentGenCell.south != null && !currentGenCell.south.genVisited && currentGenCell.south.allWallsIntact) { currentNeighbors.add(currentGenCell.south); logger.writeInLog( "Adding south cell to neighbors at: " + currentGenCell.south.gridPosX + "; " + currentGenCell.south.gridPosY); } if (currentGenCell.west != null && !currentGenCell.west.genVisited && currentGenCell.west.allWallsIntact) { currentNeighbors.add(currentGenCell.west); logger.writeInLog( "Adding west cell to neighbors at: " + currentGenCell.west.gridPosX + "; " + currentGenCell.west.gridPosY); } if (currentNeighbors.size() > 0) { Random random = new Random(); int randomValue = random.nextInt(currentNeighbors.size()); logger.writeInLog("Generated random number: " + randomValue); Cell neighbor = currentNeighbors.get(randomValue); logger.writeInLog("Picked neighbor: " + neighbor.gridPosX + "; " + neighbor.gridPosY); neighbor.genVisited = true; int wallX = 0; int wallY = 0; // break wall if (neighbor.gridPosX > currentGenCell.gridPosX) { wallX = currentGenCell.gridPosX + 1; } else if (neighbor.gridPosX < currentGenCell.gridPosX) { wallX = currentGenCell.gridPosX - 1; } else { wallX = currentGenCell.gridPosX; } if (neighbor.gridPosY > currentGenCell.gridPosY) { wallY = currentGenCell.gridPosY + 1; } else if (neighbor.gridPosY < currentGenCell.gridPosY) { wallY = currentGenCell.gridPosY - 1; } else { wallY = currentGenCell.gridPosY; } cells[wallX][wallY].wall = false; cells[wallX][wallY].genVisited = true; logger.writeInLog("Breaking wall at: " + wallX + "; " + wallY); genVisited.add(cells[wallX][wallY]); neighbor.genBacktrack = currentGenCell; logger.writeInLog( "Set current cell to backtrack cell at: " + currentGenCell.gridPosX + "; " + currentGenCell.gridPosY); currentGenCell = neighbor; } else { currentGenCell = currentGenCell.genBacktrack; logger.writeInLog( "Backtracking at: " + currentGenCell.genBacktrack.gridPosX + "; " + currentGenCell.genBacktrack.gridPosY); } } else { currentGenCell = null; this.maze = false; setDefaultStartAndEnd(true); displayingMaze = true; if ((this.search = !this.search) == true) { if (this.startSearch == false) { this.search = false; createImage(); } } logger.writeInLog("Done Maze, closing logger."); logger.closeWriter(); if (this.automaticallyGenerateMazes && (generatedMazes < mazesToGenerate)) { generatedMazes += 1; clear(); createGraph(); this.maze = true; } else if (this.logger.stepList.size() != 0) { this.logger.printStepList(); } else {; } } } } char[][] copyOfLevel = new char[CELLS][CELLS]; for (int x = 0; x < cells.length; x++) { for (int y = 0; y < cells.length; y++) { if (cells[x][y].wall) { copyOfLevel[x][y] = 'W'; } else if (!cells[x][y].wall) { copyOfLevel[x][y] = 'D'; } else if (cells[x][y].start) { copyOfLevel[x][y] = 'S'; } else if (cells[x][y].goal) { copyOfLevel[x][y] = 'G'; } else { copyOfLevel[x][y] = 'D'; } } } Level.update(copyOfLevel); }
/** 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; } }