Skip to content

Commit

Permalink
non invasive rerendering through old board state safe and reuse for a…
Browse files Browse the repository at this point in the history
…fter board manipulation
  • Loading branch information
mklemmingen committed Jan 13, 2024
1 parent c961ed5 commit 28c8c4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/com/boomchess/game/BoomChess.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public class BoomChess extends ApplicationAdapter {
// ------------------------------------------------------

// if on desktop, false, android if true, sets the resizing by tileSize and UI size
public static boolean publisher = false;
public static boolean publisher = true;

// ------------------------------------------------------

Expand Down
19 changes: 17 additions & 2 deletions core/src/com/boomchess/game/frontend/stage/GameStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ public void dragStart(InputEvent event, float x, float y, int pointer) {
String tileTeamColor = gameBoard[finalI][finalJ].getTeamColor();

// If it's not the current team's turn, cancel the drag and return
if ((currentState == BoomChess.GameState.RED_TURN && !tileTeamColor.equals("red")) ||
(currentState == BoomChess.GameState.GREEN_TURN && !tileTeamColor.equals("green"))) {
if ((currentState == BoomChess.GameState.RED_TURN && tileTeamColor.equals("green")) ||
(currentState == BoomChess.GameState.GREEN_TURN && tileTeamColor.equals("red"))) {
event.cancel();

// adds a logo on screen that says that the movement was not allowed yet
Expand All @@ -417,6 +417,19 @@ public void dragStart(InputEvent event, float x, float y, int pointer) {
//plays a brick sound
indi.makeSound();

nonInvasiveReRender = true;
BoomChess.reRenderGame();
return;
} else if (currentState == BoomChess.GameState.RED_TURN && !tileTeamColor.equals("red") ||
currentState == BoomChess.GameState.GREEN_TURN && !tileTeamColor.equals("green")) {
// player tried moving a piece that is of an empty soldier,
// cancel event, do not add indicator, do not make a sound and non invasive rerender

// explanation: there is red, green and EMPTY

event.cancel();

nonInvasiveReRender = true;
BoomChess.reRenderGame();
return;
}
Expand Down Expand Up @@ -655,6 +668,7 @@ public void changed(ChangeEvent event, Actor actor) {
intervalsButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
nonInvasiveReRender = true;
BoomChess.showIntervals = !BoomChess.showIntervals;
reRenderGame();
}
Expand All @@ -671,6 +685,7 @@ public void changed(ChangeEvent event, Actor actor) {
@Override
public void changed(ChangeEvent event, Actor actor) {
showHealth = !showHealth;
nonInvasiveReRender = true;
reRenderGame();
}
});
Expand Down

0 comments on commit 28c8c4d

Please sign in to comment.