Skip to content

Commit da0cad7

Browse files
committed
added Help to all Modes
1 parent 82f31f9 commit da0cad7

File tree

6 files changed

+70
-49
lines changed

6 files changed

+70
-49
lines changed

assets/Misc/rules.png

838 KB
Loading

core/src/com/boomchess/game/BoomChess.java

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ public class BoomChess extends ApplicationAdapter {
250250
public static Stage wrongMoveStage;
251251
public static Texture wrongMoveLogo;
252252
public static Sound brick;
253+
254+
// for the help stage and the help button
255+
public static Stage helpStage;
256+
public static Texture helpTexture;
257+
public static boolean showHelp;
253258
// -----------------------------------------------------------------------------------------
254259

255260

@@ -279,6 +284,7 @@ public void create() {
279284
moveLogoStage = new Stage(new ScreenViewport());
280285
possibleMoveOverlay = new Stage(new ScreenViewport());
281286
wrongMoveStage = new Stage(new ScreenViewport());
287+
helpStage = new Stage(new ScreenViewport());
282288

283289
// initialises the tile size for relative positioning of stages
284290
RelativeResizer.init(); // sets public tilesize variable
@@ -422,6 +428,11 @@ public void render() {
422428
}
423429
sequenceRunning = false;
424430

431+
if(showHelp){
432+
helpStage.act();
433+
helpStage.draw();
434+
}
435+
425436
if(inGame){
426437
// make a turn check if the game is in progress
427438
processTurn();
@@ -527,6 +538,9 @@ private static void loadAllAssets(){
527538

528539
empty = new Texture(Gdx.files.internal("Misc/empty.png"));
529540

541+
// help texture
542+
helpTexture = new Texture(Gdx.files.internal("Misc/rules.png"));
543+
530544
// Loading Texture of the map
531545

532546
medievalMaps = new RandomImage();
@@ -902,6 +916,13 @@ public void changed(ChangeEvent event, Actor actor) {
902916

903917
sequenceRunning = false;
904918

919+
// help Stage
920+
921+
Image helpImage = new Image(helpTexture);
922+
helpImage.setSize(tileSize*12.5f, tileSize*8);
923+
helpImage.setPosition(tileSize*4.1f, tileSize*1.9f);
924+
helpStage.addActor(helpImage);
925+
905926
// leaves the loading screen
906927
assetsLoaded = true;
907928
}
@@ -1123,18 +1144,43 @@ public static void createMainMenuStage() {
11231144
gameEndStage.clear();
11241145
}
11251146

1126-
public static void createHelpStage() {
1147+
public static void createOptionsStage() {
11271148
/*
1128-
* method for creating the stage for the help display
1149+
* method for creating the stage for the options display
11291150
*/
1130-
switchToStage(HelpStage.initializeUI());
1151+
switchToStage(OptionsStage.initalizeUI());
11311152
}
11321153

1133-
public static void createOptionsStage() {
1154+
public static void createHelpStage() {
11341155
/*
1135-
* method for creating the stage for the options display
1156+
* method for creating the stage for the help display
11361157
*/
1137-
switchToStage(OptionsStage.initalizeUI());
1158+
Stage funcStage = new Stage();
1159+
1160+
Table funcTable = new Table();
1161+
1162+
Image helpImage = new Image(helpTexture);
1163+
helpImage.setSize(tileSize*12.5f, tileSize*8);
1164+
helpImage.setPosition(tileSize*4.1f, tileSize*1.9f);
1165+
funcTable.addActor(helpImage);
1166+
1167+
funcTable.row();
1168+
1169+
// button to go back to the menu
1170+
TextButton backButton = new TextButton("Back", skin);
1171+
backButton.setPosition((float) Gdx.graphics.getWidth() /2,
1172+
(float) Gdx.graphics.getHeight() /8);
1173+
backButton.addListener(new ChangeListener() {
1174+
@Override
1175+
public void changed(ChangeEvent event, Actor actor) {
1176+
createMainMenuStage();
1177+
}
1178+
});
1179+
funcTable.addActor(backButton);
1180+
1181+
funcStage.addActor(funcTable);
1182+
1183+
switchToStage(funcStage);
11381184
}
11391185

11401186
public static void createCreditsStage() {

core/src/com/boomchess/game/frontend/picture/SpeechBubbles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void createSpeechAttackIncoming(){
3434
generalCoordinates = BoomChess.findGeneral(true);
3535
}
3636
else{
37-
return; // we dont need a bot to tell us that an attack is incoming
37+
return; // we don't need a bot to tell us that an attack is incoming
3838
}
3939
}
4040
else{

core/src/com/boomchess/game/frontend/stage/GameStage.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ public void dragStop(InputEvent event, float x, float y, int pointer) {
299299
if (!isBotMatch) {
300300
backTable.setSize(tileSize*5, tileSize*1.5f); // determines the frame size for the backTable (button: to main menu)
301301
// bottom right the table in the parent container
302-
backTable.setPosition(Gdx.graphics.getWidth() - backTable.getWidth(), tileSize/3);
302+
backTable.setPosition(Gdx.graphics.getWidth() - backTable.getWidth(), tileSize/2.5f);
303303
} else {
304304
backTable.setSize(tileSize*5, tileSize*2);
305305
// bottom right the table in the parent container
306-
backTable.setPosition(Gdx.graphics.getWidth() - backTable.getWidth(), tileSize/4);}
306+
backTable.setPosition(Gdx.graphics.getWidth() - backTable.getWidth(), tileSize/3.5f);}
307307
gameStage.addActor(backTable); // Add the table to the stage
308308

309309
if(isBotMatch) {
@@ -331,6 +331,18 @@ public void changed(ChangeEvent event, Actor actor) {
331331
});
332332
}
333333

334+
// help button
335+
backTable.row().padBottom(tileSize/8);
336+
TextButton helpButton = new TextButton("Help", skin);
337+
helpButton.align(Align.bottomRight);
338+
backTable.add(helpButton);
339+
helpButton.addListener(new ChangeListener() {
340+
@Override
341+
public void changed(ChangeEvent event, Actor actor) {
342+
showHelp = !showHelp;
343+
}
344+
});
345+
334346
backTable.row().padBottom(tileSize/8);
335347
// Button to change 1.Player Colour to blue
336348
TextButton changeColourButton = new TextButton("Switch 1P Skin", skin);
@@ -396,6 +408,7 @@ public void changed(ChangeEvent event, Actor actor) {
396408
BoomChess.currentState = BoomChess.GameState.NOT_IN_GAME;
397409

398410
inGame = false;
411+
showHelp = false;
399412

400413
createMainMenuStage();
401414
}

core/src/com/boomchess/game/frontend/stage/HelpStage.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

core/src/com/boomchess/game/frontend/stage/MenuStage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public static Stage initializeUI() {
4646
helpButton.addListener(new ChangeListener() {
4747
@Override
4848
public void changed(ChangeEvent event, Actor actor) {
49-
BoomChess.createHelpStage();
49+
// switch showHelp, if on, turn off, if off, turn on
50+
createHelpStage();
5051
}
5152
});
5253
root.row();

0 commit comments

Comments
 (0)