diff --git a/assets/music/egyptianmusic.mp3 b/assets/music/egyptianmusic.mp3 new file mode 100644 index 0000000..ecc12a8 Binary files /dev/null and b/assets/music/egyptianmusic.mp3 differ diff --git a/assets/music/egyptianmusic2.mp3 b/assets/music/egyptianmusic2.mp3 new file mode 100644 index 0000000..3eab4a5 Binary files /dev/null and b/assets/music/egyptianmusic2.mp3 differ diff --git a/assets/music/egyptreconstruct.mp3 b/assets/music/egyptreconstruct.mp3 new file mode 100644 index 0000000..bf837d0 Binary files /dev/null and b/assets/music/egyptreconstruct.mp3 differ diff --git a/assets/textures/armabovein.png b/assets/textures/armabovein.png new file mode 100644 index 0000000..fc03bf0 Binary files /dev/null and b/assets/textures/armabovein.png differ diff --git a/assets/textures/armbelowin.png b/assets/textures/armbelowin.png new file mode 100644 index 0000000..97b8d13 Binary files /dev/null and b/assets/textures/armbelowin.png differ diff --git a/assets/textures/background.png b/assets/textures/background.png new file mode 100644 index 0000000..50e8237 Binary files /dev/null and b/assets/textures/background.png differ diff --git a/core/src/com/senetboom/game/SenetBoom.java b/core/src/com/senetboom/game/SenetBoom.java index 6670c4d..3cc057e 100644 --- a/core/src/com/senetboom/game/SenetBoom.java +++ b/core/src/com/senetboom/game/SenetBoom.java @@ -12,13 +12,12 @@ import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.ScreenUtils; import com.senetboom.game.backend.*; import com.senetboom.game.frontend.actors.ExtraTurnActor; +import com.senetboom.game.frontend.sound.MusicPlaylist; import com.senetboom.game.frontend.stages.GameStage; import com.senetboom.game.frontend.stages.MainMenu; -import com.senetboom.game.frontend.special.RelativeResizer; import com.senetboom.game.frontend.text.Typewriter; import com.badlogic.gdx.scenes.scene2d.ui.Stack; import com.badlogic.gdx.scenes.scene2d.ui.Table; @@ -72,9 +71,6 @@ public class SenetBoom extends ApplicationAdapter { static Stage helpOverlayStage; Texture help; public static boolean displayHelp; - - // handStage - Stage handStage; Texture hand; // for the pieces textures unselected public static Texture blackpiece; @@ -194,6 +190,19 @@ public class SenetBoom extends ApplicationAdapter { public static boolean needRender; + // for the arms + public static Image armFromBelow; + public static Image armFromAbove; + + // for the advanced arm stages and their respective boolean + + public static Stage armFromBelowStage; + public static Stage armFromAboveStage; + public static boolean showArmFromBelowStage; + public static boolean showArmFromAboveStage; + + public static MusicPlaylist musicPlaylist; + // enum of turn private enum Turn { PLAYERWHITE, @@ -203,7 +212,7 @@ private enum Turn { @Override public void create () { batch = new SpriteBatch(); - background = new Texture("textures/egypt.png"); + background = new Texture("textures/background.png"); // from scene2dUi currentStage = new Stage(); @@ -218,7 +227,6 @@ public void create () { typeWriterStage = new Stage(); hitStage = new Stage(); helpOverlayStage = new Stage(); - handStage = new Stage(); mapStage = new Stage(); extraTurnStage = new Stage(); stickValueStage = new Stage(); @@ -226,6 +234,13 @@ public void create () { hintStage = new Stage(); currentTurnStage = new Stage(); + // for the arms + + armFromBelowStage = new Stage(); + armFromAboveStage = new Stage(); + showArmFromBelowStage = false; + showArmFromAboveStage = false; + // possible Moves is a ArrayList of int values possibleMoves = new ArrayList(); @@ -240,8 +255,6 @@ public void create () { // loading all textures blackpiece = new Texture("textures/blackpiece.png"); whitepiece = new Texture("textures/whitepiece.png"); - // blackpieceSelected = new Texture("textures/blackpieceSelected.png"); - // whitepieceSelected = new Texture("textures/whitepieceSelected.png"); happy = new Texture("textures/happy.png"); water = new Texture("textures/water.png"); safe = new Texture("textures/safe.png"); @@ -254,6 +267,17 @@ public void create () { whiteStarts = new Texture("textures/whiteStart.png"); blackStarts = new Texture("textures/blackStarts.png"); + // arms + + armFromAboveStage = new Stage(); + armFromBelowStage = new Stage(); + + armFromAbove = new Image(new Texture("textures/armabovein.png")); + armFromBelow = new Image(new Texture("textures/armbelowin.png")); + + armFromAboveStage.addActor(armFromAbove); + armFromBelowStage.addActor(armFromBelow); + // for the sticks blackStick = new Texture("textures/blackStick.png"); whiteStick = new Texture("textures/whiteStick.png"); @@ -282,6 +306,21 @@ public void create () { // for the empty tile texture emptyTexture = new Texture("textures/empty.png"); + // music Playlist + + volume = 0.5f; + + musicPlaylist = new MusicPlaylist(); + + // from youtube: https://www.youtube.com/watch?v=nBmWXmn11YE + musicPlaylist.addSong("music/egyptreconstruct.mp3"); + // from youtube: https://www.youtube.com/watch?v=mECTRQ0VEyU + musicPlaylist.addSong("music/egyptianmusic.mp3"); + // from youtube: https://www.youtube.com/watch?v=d7jKP_JngC8 + musicPlaylist.addSong("music/egyptianmusic2.mp3"); + + musicPlaylist.play(); + // for the empty variable (the tile that is currently moved by a bot) emptyVariable = -1; @@ -382,11 +421,6 @@ public void render () { hintStage.draw(); } - // for the hand texture that follow the drag position of the piece - // depending on if white or black (from up or from down) - handStage.act(); - handStage.draw(); - // for the extra turn symbol extraTurnStage.act(); extraTurnStage.draw(); @@ -405,6 +439,17 @@ public void render () { return; } + // for the arms + if(showArmFromBelowStage) { + armFromBelowStage.act(); + armFromBelowStage.draw(); + } + + if(showArmFromAboveStage) { + armFromAboveStage.act(); + armFromAboveStage.draw(); + } + // for the display of the game having ended gameEndStage.act(); gameEndStage.draw(); @@ -553,13 +598,14 @@ public void resize(int width, int height) { typeWriterStage.getViewport().update(width, height, true); hitStage.getViewport().update(width, height, true); helpOverlayStage.getViewport().update(width, height, true); - handStage.getViewport().update(width, height, true); gameEndStage.getViewport().update(width, height, true); extraTurnStage.getViewport().update(width, height, true); stickValueStage.getViewport().update(width, height, true); deciderStage.getViewport().update(width, height, true); hintStage.getViewport().update(width, height, true); currentTurnStage.getViewport().update(width, height, true); + armFromAboveStage.getViewport().update(width, height, true); + armFromBelowStage.getViewport().update(width, height, true); } } @@ -621,7 +667,7 @@ public Decider(Turn turn){ } this.X = tileSize*8; - this.Y = tileSize*2; + this.Y = tileSize*8; } @Override @@ -678,7 +724,7 @@ public void dispose () { blackStarts.dispose(); } - public static Coordinate calculatePXbyTile(int x, int y) { + public static Coordinate calculatePXbyTile(int x) { // the screen is 1536 to 896. The board is 3x10 tiles and each tile is 80x80px. // the board is centered on the screen int screenWidth = 1536; @@ -686,22 +732,26 @@ public static Coordinate calculatePXbyTile(int x, int y) { int boardWidth = (int) (tileSize * 10); int boardHeight = (int) (tileSize * 3); - // Calculate starting position of the board + // Calculate starting position (upper left corner) of the board int boardStartX = (screenWidth - boardWidth) / 2; int boardStartY = (screenHeight - boardHeight) / 2; - // Calculate tile position - int posX, posY; + int yCoord; + int xCoord; - if (y == 1) { // Middle row (reversed) - posX = (int) (boardStartX + (9 - x) * tileSize); - } else { // Top and bottom rows - posX = (int) (boardStartX + x * tileSize); + // Calculate the tile's position + if(x <= 9){ + yCoord = boardStartY + 80; + xCoord = boardStartX + (x * 80); + } else if (x <= 19){ + yCoord = boardStartY; + xCoord = boardStartX + (10*80) - ((x-9)*80); + } else { + yCoord = boardStartY - (80); + xCoord = boardStartY * ((x-19) * 80); } - posY = (int) (boardStartY + y * tileSize); - - return new Coordinate(posX, posY); + return new Coordinate(xCoord, yCoord); } public static int calculateTilebyPx(int x, int y) { @@ -715,7 +765,7 @@ public static int calculateTilebyPx(int x, int y) { int boardStartX = (screenWidth - boardWidth) / 2; int boardStartY = (screenHeight - boardHeight) / 2; - // Adjust the y-coordinate to reflect libGDX's top-left origin + // Adjust the y-coordinate to reflect libGDX's bottom-left origin int adjustedY = screenHeight - y; // Calculate which tile diff --git a/core/src/com/senetboom/game/backend/Tile.java b/core/src/com/senetboom/game/backend/Tile.java index 089b9c3..2b8cd54 100644 --- a/core/src/com/senetboom/game/backend/Tile.java +++ b/core/src/com/senetboom/game/backend/Tile.java @@ -216,7 +216,9 @@ private boolean checkBlockade(Tile[] board, int start, int stickRoll, Piece.Colo @Override public void movePiece(int newIndex) { int index = position; // starter position + Tile[] board = Board.getBoard(); + Piece piece = board[index].getPiece(); // rebirth case: @@ -256,6 +258,7 @@ public void movePiece(int newIndex) { for (int i = 13; i >= 0; i--) { if (!board[i].hasPiece()) { board[i].setPiece(piece); // move to the earliest free tile + board[index].removePiece(); // remove the piece from the water tile break; } } @@ -263,11 +266,13 @@ public void movePiece(int newIndex) { // if tile 14 is free, move the piece there and give it protection board[14].setPiece(piece); piece.switchProtection(); // give protection to the piece + board[index].removePiece(); // remove the piece from the water tile } break; case REBIRTH: // add rebirth protection piece.switchProtection(); + break; case SAFE: // do nothing for SAFE state diff --git a/core/src/com/senetboom/game/frontend/actors/ExtraTurnActor.java b/core/src/com/senetboom/game/frontend/actors/ExtraTurnActor.java index beaf82d..77a0fb1 100644 --- a/core/src/com/senetboom/game/frontend/actors/ExtraTurnActor.java +++ b/core/src/com/senetboom/game/frontend/actors/ExtraTurnActor.java @@ -31,7 +31,7 @@ public ExtraTurnActor(){ stack.setSize(tileSize*4, tileSize*2); stack.addActor(new Image(extraTurnTexture)); this.X = tileSize*8; - this.Y = tileSize*4; + this.Y = tileSize*8; } @Override diff --git a/core/src/com/senetboom/game/frontend/special/moveBotTile.java b/core/src/com/senetboom/game/frontend/special/moveBotTile.java index dced7f4..b5bb0ac 100644 --- a/core/src/com/senetboom/game/frontend/special/moveBotTile.java +++ b/core/src/com/senetboom/game/frontend/special/moveBotTile.java @@ -53,8 +53,8 @@ public void startMove(int startX, int startY, int endX, int endY) { // set the maximum duration fitting the length of the way that the soldier moves // per 50 pixel, add 0.5f to max duration // Begin: calculate Vector: - startPx = SenetBoom.calculatePXbyTile(startX, startY); - endPx = SenetBoom.calculatePXbyTile(endX, endY); + startPx = SenetBoom.calculatePXbyTile(startX); + endPx = SenetBoom.calculatePXbyTile(endX); Vector2 pointA = new Vector2(startPx.getX(), startPx.getY()); Vector2 pointB = new Vector2(endPx.getX(), endPx.getY()); diff --git a/core/src/com/senetboom/game/frontend/stages/GameStage.java b/core/src/com/senetboom/game/frontend/stages/GameStage.java index 87e8b97..ef1f670 100644 --- a/core/src/com/senetboom/game/frontend/stages/GameStage.java +++ b/core/src/com/senetboom/game/frontend/stages/GameStage.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.senetboom.game.SenetBoom; import com.senetboom.game.backend.Board; +import com.senetboom.game.backend.Coordinate; import com.senetboom.game.backend.Piece; import com.senetboom.game.backend.Tile; import com.badlogic.gdx.math.Vector2; @@ -100,7 +101,7 @@ public static Stage drawBoard() { helpButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { - SenetBoom.displayHelp = !SenetBoom.displayHelp; + displayHelp = !displayHelp; } }); exitTable.add(helpButton).padBottom(tileSize/4); @@ -110,7 +111,7 @@ public void changed(ChangeEvent event, Actor actor) { hintButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { - SenetBoom.displayHint = !SenetBoom.displayHint; + displayHint = !displayHint; needRender = true; } }); @@ -122,7 +123,7 @@ public void changed(ChangeEvent event, Actor actor) { skipTurnButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { - SenetBoom.skipTurn = true; + skipTurn = true; } }); exitTable.add(skipTurnButton).padBottom(tileSize/4); @@ -144,7 +145,7 @@ public void changed(ChangeEvent event, Actor actor) { exitButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { - SenetBoom.createMenu(); + createMenu(); } }); exitTable.add(exitButton).padBottom(tileSize/4); @@ -162,11 +163,11 @@ public static void createStacks(final Tile[] board, Table pawnRoot, final int i) // for the stack above being the pawn on the tile final Stack pawnStack = new Stack(); - pawnStack.setSize(tileSize, tileSize); + pawnStack.setSize(80, 80); // EMPTY Texture Image empty = new Image(emptyTexture); - empty.setSize(tileSize, tileSize); + empty.setSize(80, 80); pawnStack.addActor(empty); // if the tile has a piece, draw the piece @@ -181,7 +182,7 @@ public static void createStacks(final Tile[] board, Table pawnRoot, final int i) // draw a white piece to the stack piece = new Image(whitepiece); } - piece.setSize(tileSize, tileSize); + piece.setSize(80, 80); pawnStack.addActor(piece); } } @@ -190,11 +191,11 @@ public static void createStacks(final Tile[] board, Table pawnRoot, final int i) if(tile.hasPiece() && tile.getPiece().hasProtection()) { // draw a protection to the stack Image protection = new Image(rebirthProtection); - protection.setSize(tileSize, tileSize); + protection.setSize(80, 80); pawnStack.addActor(protection); } - if(tile.hasPiece() && tile.getPiece().getColour() == SenetBoom.getTurn()){ + if(tile.hasPiece() && tile.getPiece().getColour() == getTurn()){ // drag and drop listeners pawnStack.addListener(new DragListener() { @@ -204,14 +205,14 @@ public void dragStart(InputEvent event, float x, float y, int pointer) { System.out.println("Started dragging the Pawn!\n"); // Get the team color of the current tile - Tile[] gameBoard = Board.getBoard(); + Tile[] gameBoard = getBoard(); Piece.Color teamColor = gameBoard[i].getPiece().getColour(); // If it's not the current team's turn, cancel the drag and return - if (!(teamColor == SenetBoom.getTurn())) { + if (!(teamColor == getTurn())) { event.cancel(); System.out.println("It's not your turn!\n"); - SenetBoom.renderBoard(); + renderBoard(); return; } @@ -225,13 +226,23 @@ public void dragStart(InputEvent event, float x, float y, int pointer) { System.out.println("Move for this piece invalid"); } - /* - board[i].getPiece().checkMove(board[i].getPosition(), currentStickValue); - */ - pawnStack.toFront(); // bring to the front + Coordinate cd = calculatePXbyTile(board[i].getPosition()); + // If it's the current team's turn, continue with the drag + // show the current teams arm stage + if (teamColor == Piece.Color.BLACK) { + // draw a black arm to the stack + showArmFromBelowStage = true; + float armFromBelowY = cd.getY()-(tileSize*7.25f)-10; + armFromBelow.setPosition(cd.getX()-tileSize*0.5f, armFromBelowY); + } else { + // draw a white arm to the stack + showArmFromAboveStage = true; + armFromAbove.setPosition(cd.getX()-tileSize*0.5f, cd.getY()+tileSize*1.5f); + } + } @Override @@ -240,6 +251,16 @@ public void drag(InputEvent event, float x, float y, int pointer) { // Code here will run during the dragging // move by the difference between the current position and the last position pawnStack.moveBy(x - pawnStack.getWidth() / 2, y - pawnStack.getHeight() / 2); + + // set the arm position to the current position of the pawn + if (getTurn() == Piece.Color.BLACK) { + // draw a black arm to the stack + armFromBelow.moveBy(x - pawnStack.getWidth() / 2, y - pawnStack.getHeight() / 2); + } else { + // draw a white arm to the stack + armFromAbove.moveBy(x - pawnStack.getWidth() / 2, y - pawnStack.getHeight() / 2); + } + } @Override @@ -254,7 +275,7 @@ public void dragStop(InputEvent event, float x, float y, int pointer) { System.out.println("\n Drag stopped at screen position: " + screenCoords.x + ", " + screenCoords.y + "\n"); - int endTile = SenetBoom.calculateTilebyPx((int) screenCoords.x, (int) screenCoords.y); + int endTile = calculateTilebyPx((int) screenCoords.x, (int) screenCoords.y); System.out.print("End Tile: " + endTile + "\n"); // for loop through validMoveTiles, at each tile we check for equality of currentCoord @@ -269,7 +290,7 @@ public void dragStop(InputEvent event, float x, float y, int pointer) { if(endTile == possibleMove){ // Board.update with oldX, oldY, newX, newY board[tile.getPosition()].movePiece(endTile); - SenetBoom.legitMove = true; + legitMove = true; System.out.println("Move valid as in check of tile to possibleMove"); } else { System.out.println("Move invalid as in check of tile to possibleMove"); @@ -278,8 +299,12 @@ public void dragStop(InputEvent event, float x, float y, int pointer) { // and the possibleMove is cleared possibleMove = -1; // for turning off the Overlay + // turn off the arm stage + showArmFromBelowStage = false; + showArmFromAboveStage = false; + // board is rendered new - SenetBoom.renderBoard(); + renderBoard(); } }); // end of listener creation }