Skip to content

Commit

Permalink
menu music sound change
Browse files Browse the repository at this point in the history
  • Loading branch information
mklemmingen committed Jan 13, 2024
1 parent e1ae016 commit c961ed5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/src/com/boomchess/game/BoomChess.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ public class BoomChess extends ApplicationAdapter {
// ------------------------------------------------------

public static boolean dogIsJeep = true;
public static boolean nonInvasiveReRender = false;

@Override
public void create() {
Expand Down Expand Up @@ -1478,6 +1479,7 @@ public void changed(ChangeEvent event, Actor actor) {
@Override
public void changed(ChangeEvent event, Actor actor) {
isColourChanged = !isColourChanged;
nonInvasiveReRender = true;
currentStage = GameStage.createGameStage(isBotMatch);
addAudioTable();
createInGameOptionStages();
Expand Down Expand Up @@ -1539,6 +1541,7 @@ public void changed(ChangeEvent event, Actor actor) {
attackCircleButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
nonInvasiveReRender = true;
showAttackCircle = !showAttackCircle;
createInGameOptionStages();
}
Expand Down Expand Up @@ -1581,6 +1584,7 @@ public void changed(ChangeListener.ChangeEvent event, Actor actor) {
dogIsCarButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
nonInvasiveReRender = true;
dogIsJeep = !dogIsJeep;
createInGameOptionStages();
}
Expand All @@ -1604,6 +1608,7 @@ public void changed(ChangeEvent event, Actor actor) {
animationButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
nonInvasiveReRender = true;
isAnimated = !isAnimated;
createInGameOptionStages();
}
Expand Down
13 changes: 12 additions & 1 deletion core/src/com/boomchess/game/frontend/stage/GameStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

public class GameStage {

// used for nonInvasive reRendering
private static Soldier[][] lastGameBoard = new Soldier[9][8];

private static boolean showHealth = false;

private final Stage gameStage;
Expand Down Expand Up @@ -75,7 +78,12 @@ public static Stage createGameStage(final boolean isBotMatch) {
root.setPosition((float) Gdx.graphics.getWidth() / 2 - root.getWidth() / 2,
(float) Gdx.graphics.getHeight() / 2 - root.getHeight() / 2);

Soldier[][] gameBoard = Board.getGameBoard();
Soldier[][] gameBoard;
if(nonInvasiveReRender){
gameBoard = lastGameBoard;
} else {
gameBoard = Board.getGameBoard();
}

for (int j = 0; j < numRows; j++) {
root.row();
Expand Down Expand Up @@ -707,6 +715,9 @@ public void changed(ChangeEvent event, Actor actor) {
}
});

lastGameBoard = gameBoard;
nonInvasiveReRender = false;

return gameStage;
}

Expand Down

0 comments on commit c961ed5

Please sign in to comment.