Skip to content

Commit

Permalink
Tutorial and ui improv
Browse files Browse the repository at this point in the history
  • Loading branch information
mklemmingen committed Dec 30, 2023
1 parent 549e200 commit f8f8755
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 37 deletions.
Binary file added assets/Misc/katIncluded.mp3
Binary file not shown.
Binary file added assets/Misc/tutorial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Misc/tutorialsound.mp3
Binary file not shown.
28 changes: 24 additions & 4 deletions core/src/com/boomchess/game/BoomChess.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public class BoomChess extends ApplicationAdapter {

// universal Buttons -- here for music and sound control

public static Button playButton;
public static TextButton playButton;

public static Button muteButton;
public static TextButton muteButton;

public static Button skipButton;

Expand Down Expand Up @@ -276,6 +276,14 @@ public class BoomChess extends ApplicationAdapter {

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

// tutorial and loading screen

public static Sound katIncluded;
public static Music tutorialSound;

public static Texture tutorialTexture;
public static boolean inTutorial = false;


@Override
public void create() {
Expand All @@ -287,6 +295,8 @@ public void create() {
loadingScreenTextures = new RandomImage();
loadingScreenTextures.addTexture("loadingScreen/loadingScreen2.png");
loadingSound = Gdx.audio.newSound(Gdx.files.internal("sounds/countdown.mp3"));
tutorialSound = Gdx.audio.newMusic(Gdx.files.internal("Misc/tutorialsound.mp3"));
tutorialTexture = new Texture(Gdx.files.internal("Misc/tutorial.png"));
loadingStage = LoadingScreenStage.initalizeUI();

// creating all stage objects
Expand All @@ -312,6 +322,7 @@ public void create() {

background = new Texture(Gdx.files.internal("backgrounds/background_5.png"));
boomSoftwares = Gdx.audio.newSound(Gdx.files.internal("Misc/BoomSoftwares.mp3"));
katIncluded = Gdx.audio.newSound(Gdx.files.internal("Misc/katIncluded.mp3"));

loadingScreenIsRunning = true;
}
Expand Down Expand Up @@ -782,9 +793,9 @@ private static void loadAllAssets(){

// ---------------------------- universal Buttons for adding to stages

playButton = new Button(skin, "music");
playButton = new TextButton("Play", skin);

muteButton = new Button(skin, "sound");
muteButton = new TextButton("Mute", skin);

skipButton = new TextButton("skip", skin);

Expand All @@ -807,9 +818,15 @@ public void clicked(InputEvent event, float x, float y) {
// if in game state - play background_music
if (currentState != GameState.NOT_IN_GAME) {
if(background_music.isPlaying()) {
if(inTutorial) {
tutorialSound.stop();
}
background_music.stop();
background_music.setVolume(0);
} else {
if(inTutorial) {
tutorialSound.play();
}
background_music.play();
background_music.setVolume(volume);
}
Expand All @@ -830,6 +847,7 @@ public void clicked(InputEvent event, float x, float y) {
public void clicked(InputEvent event, float x, float y) {
// if in game state - play background_music
if (volume == 0) {
tutorialSound.setVolume(1);
volume = 0.1f;
soundVolume = 0.1f;
volumeSlider.setValue(0.1f);
Expand All @@ -840,6 +858,7 @@ public void clicked(InputEvent event, float x, float y) {
menu_music.setVolume(volume);
}
} else {
tutorialSound.setVolume(0);
volume = 0;
soundVolume = 0;
volumeSlider.setValue(0);
Expand Down Expand Up @@ -1323,6 +1342,7 @@ public static void createMainMenuStage() {
/*
* method for creating the stage for the main menu
*/
inTutorial = false;
switchToStage(MenuStage.initializeUI());
gameEndStage.clear();
}
Expand Down
42 changes: 42 additions & 0 deletions core/src/com/boomchess/game/backend/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,48 @@ public static void initialiseChallengeFifteen(){
}
*/

public static void initialiseTutorialBoard(){
// declaring the board

board = new Soldier[9][8];

// initialize the board with the correct pieces for the 2.Challenge

// green red
// 0 1 2 3 4 5 6 7 8
// 0 o
// 1 o
// 2
// 3 g a i i g
// 4
// 5 o
// 6 o
// 7

// start of the creation of the board

// infantry
board[3][3] = new Infantry("green");
board[6][3] = new Infantry("red");

// generals
board[1][3] = new General("green");
board[7][3] = new General("red");

// artillery
board[2][3] = new Artillery("green");

// obstacles
board[2][1] = new Hill("empty");
board[5][0] = new Hill("empty");
board[4][5] = new Hill("empty");
board[0][6] = new Hill("empty");


// empty tiles ( all unused ones )
fillNullOfEmptyTiles();
}

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

private static void fillNullOfEmptyTiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void changed(ChangeListener.ChangeEvent event, Actor actor) {
// button to start the third challenge
TextButton challenge3Button = new TextButton("Challenge 3: Artillery Hell", skin);
root.add(challenge3Button).padBottom(tileSize/4);
challenge2Button.addListener(new ChangeListener() {
challenge3Button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {

Expand Down
9 changes: 9 additions & 0 deletions core/src/com/boomchess/game/frontend/stage/GameStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ public void dragStop(InputEvent event, float x, float y, int pointer) {

gameStage.addActor(root);

if(inTutorial){
// add tutorialtexture to the upper right corner
Image tutorialTexture = new Image(BoomChess.tutorialTexture);
tutorialTexture.setSize(tileSize*6, tileSize*7);
tutorialTexture.setPosition(Gdx.graphics.getWidth() - tutorialTexture.getWidth(),
Gdx.graphics.getHeight() - tutorialTexture.getHeight());
gameStage.addActor(tutorialTexture);
}


// create another table for the option buttons

Expand Down
36 changes: 30 additions & 6 deletions core/src/com/boomchess/game/frontend/stage/MenuStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,38 @@ public static Stage initializeUI() {
root.add(title).top().padBottom(tileSize/4);
root.row();

TextButton helpButton = new TextButton("Help!", skin);
root.add(helpButton).padBottom(tileSize/4);
// if help button is pressed, create a new stage for the help information
helpButton.addListener(new ChangeListener() {
TextButton TutorialButton = new TextButton("Tutorial", skin);
root.add(TutorialButton).padBottom(tileSize/4);
TutorialButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
// switch showHelp, if on, turn off, if off, turn on
createHelpStage();
/*
* method for starting the tutorial
*/

// stop menu music and start background_music
menu_music.stop();
background_music.play();
background_music.setVolume(0.05f);

currentState = GameState.GREEN_TURN;

isBotMatch = true;

// create the first gameBoard
Board.initialiseTutorialBoard();

showArm = true;

inGame = true;

botDifficulty = "medium";

inTutorial = true;

switchToStage(GameStage.createGameStage(isBotMatch));

BoomChess.tutorialSound.play();
}
});
root.row();
Expand Down
80 changes: 54 additions & 26 deletions core/src/com/boomchess/game/frontend/stage/OptionsStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ public static Stage initalizeUI() {
final Table root = new Table();
root.setFillParent(true);

root.row().padBottom(tileSize/3);
// button to change bot difficulty
// text that displays a text saying "Bot Difficulty"
String currentDif = botDifficulty;
final TextButton botDifficultyText = new TextButton("Bot Difficulty: " + currentDif, skin);
root.add(botDifficultyText).padBottom(tileSize/8);
root.add(botDifficultyText);
botDifficultyText.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Expand All @@ -41,7 +42,7 @@ public void changed(ChangeEvent event, Actor actor) {
BoomChess.createOptionsStage();
}
});
root.row();
root.row().padBottom(tileSize/3);

// Change Mode button to switch medieval and modern
String currentGameMode;
Expand All @@ -52,7 +53,7 @@ public void changed(ChangeEvent event, Actor actor) {
currentGameMode = "Modern";
}
TextButton modeGameButton = new TextButton("Switch Mode: " + currentGameMode, skin);
root.add(modeGameButton).padBottom(tileSize/8);
root.add(modeGameButton);
modeGameButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Expand All @@ -69,25 +70,55 @@ public void changed(ChangeListener.ChangeEvent event, Actor actor) {
BoomChess.createOptionsStage();
}
});
root.row();
root.row().padBottom(tileSize/3);

// text that displays a text saying "Number of Obstacles"
final TextButton numberObstaclesText = new TextButton("Number of Obstacles 0-10", skin);
root.add(numberObstaclesText).padBottom(tileSize/12);
root.row();

// slider for setting the number of obstacles in the initial no mans land
final Slider obstacleSlider;
obstacleSlider = new Slider(0, 10, 1f, false, skin);
obstacleSlider.setValue(numberObstacle);
root.add(obstacleSlider).padBottom(tileSize/8);
obstacleSlider.addListener(new ChangeListener() {
final TextButton numberObstaclesText = new TextButton(
"Change Number of Obstacles: " + numberObstacle, skin);
numberObstaclesText.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
BoomChess.numberObstacle = obstacleSlider.getValue();
switch ((int) numberObstacle) {
case 0:
numberObstacle = 1;
break;
case 1:
numberObstacle = 2;
break;
case 2:
numberObstacle = 3;
break;
case 3:
numberObstacle = 4;
break;
case 4:
numberObstacle = 5;
break;
case 5:
numberObstacle = 6;
break;
case 6:
numberObstacle = 7;
break;
case 7:
numberObstacle = 8;
break;
case 8:
numberObstacle = 9;
break;
case 9:
numberObstacle = 10;
break;
case 10:
numberObstacle = 0;
break;
}
BoomChess.createOptionsStage();
}
});
root.row();
root.add(numberObstaclesText);

root.row().padBottom(tileSize/3);;

// Change Mode button to switch blue and green
String currentMode;
Expand All @@ -98,15 +129,15 @@ public void changed(ChangeEvent event, Actor actor) {
currentMode = "Green";
}
TextButton modeButton = new TextButton("Switch 1.Player Colour: " + currentMode, skin);
root.add(modeButton).padBottom(tileSize/8);
root.add(modeButton);
modeButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
isColourChanged = !isColourChanged;
BoomChess.createOptionsStage();
}
});
root.row();
root.row().padBottom(tileSize/3);

// button to change the beep mode of the speech bubbles isBeepMode true or false
String currentBeepMode;
Expand All @@ -117,34 +148,31 @@ public void changed(ChangeListener.ChangeEvent event, Actor actor) {
currentBeepMode = "Battlefield";
}
TextButton beepModeButton = new TextButton("Speech Bubbles: " + currentBeepMode, skin);
root.add(beepModeButton).padBottom(tileSize/8);
root.add(beepModeButton);
beepModeButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
isBeepMode = !isBeepMode;
BoomChess.createOptionsStage();
}
});
root.row();
root.row().padBottom(tileSize/3);

// button for turning the arm on and off
root.row().padBottom(tileSize/8);
TextButton armButton = new TextButton("BotArm: " + showArm, skin);
root.add(armButton).padBottom(tileSize/8);
root.add(armButton);
armButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
showArm = !showArm;
createOptionsStage();
}
});

root.row();

root.row().padBottom(tileSize/3);

// back button to return to the main menu
TextButton backButton = new TextButton("Back", skin);
root.add(backButton).padBottom(tileSize/8);
root.add(backButton);
backButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Expand Down

0 comments on commit f8f8755

Please sign in to comment.