diff --git a/bin/de/bricked/resources/levelpacks/Eimer.json b/bin/de/bricked/resources/levelpacks/Eimer.json new file mode 100644 index 0000000000000000000000000000000000000000..dddf0f78a2999e5d8e45c1b9b5626cd86668ec18 --- /dev/null +++ b/bin/de/bricked/resources/levelpacks/Eimer.json @@ -0,0 +1,52 @@ +{ + "name": "THE REAL EIMER", + "author": "DeadSpaghetti", + "version": "10.0", + "levelPack": + [{ + "name": "EIMER", + "author": "DeadSpaghetti", + "position": 1, + "difficulty": 1, + "startLives": 1, + "initPadSize": "LARGE", + "board": "N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 T0 T0 T0 T0 N0 N0 T0 N0 T0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 T0 T0 N0 T0 T0 N0 N0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 T0 N0 T0 N0 T0 N0 N0 N0 N0 N0 T0 T0 T0 T0 N0 N0 T0 N0 T0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 T0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 T0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 T0 T0 T0 N0 N0 T0 N0 T0 N0 N0 N0 T0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 N0 T0 T0 T0 T0 N0 N0 T0 T0 T0 T0 N0 N0 N0 N0 N0 N0 N0 N0 T0 N0 N0 N0 N0 N0 T0 N0 N0 T0 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E0 N0 N0 T0 N0 S0 S0 S0 S0 S0 I0 I0 S0 S0 S0 S0 E0 A0 E0 N0 N0 T0 N0 N0 N0 N0 T0 S0 I0 I0 S0 N0 N0 N0 E0 A0 E0 N0 N0 T0 N0 N0 N0 N0 T0 S0 I0 I0 S0 N0 N0 N0 E0 A0 E0 N0 N0 T0 N0 N0 N0 N0 T0 S0 I0 I0 S0 N0 N0 N0 E0 A0 E0 N0 N0 T0 T0 T0 T0 T0 T0 S0 I0 I0 S0 N0 N0 N0 E0 I0 E0 S0 S0 S0 S0 S0 S0 S0 S0 S0 I0 I0 S0 I0 I0 I0 I0 I0 I0" + } + ] +} \ No newline at end of file diff --git a/bin/de/bricked/resources/levelpacks/A.json b/bin/de/bricked/resources/levelpacks/Simple_Pack.json similarity index 99% rename from bin/de/bricked/resources/levelpacks/A.json rename to bin/de/bricked/resources/levelpacks/Simple_Pack.json index 3c627f2806ba753ff88da38f82402fd1c7f34dbf..e130806b8a55498580d37f4937e47647692dd05c 100644 --- a/bin/de/bricked/resources/levelpacks/A.json +++ b/bin/de/bricked/resources/levelpacks/Simple_Pack.json @@ -1,5 +1,5 @@ { - "name": "A", + "name": "Simple Pack", "author": "DeadSpaghetti", "version": "1.0", "levelPack": diff --git a/src/de/bricked/resources/levelpacks/A.json b/bin/de/bricked/resources/levelpacks/The_amazing_DLC.json similarity index 99% rename from src/de/bricked/resources/levelpacks/A.json rename to bin/de/bricked/resources/levelpacks/The_amazing_DLC.json index 3c627f2806ba753ff88da38f82402fd1c7f34dbf..25ba2c5d24e4923b0843b99918093bdcda72805a 100644 --- a/src/de/bricked/resources/levelpacks/A.json +++ b/bin/de/bricked/resources/levelpacks/The_amazing_DLC.json @@ -1,5 +1,5 @@ { - "name": "A", + "name": "The amazing DLC", "author": "DeadSpaghetti", "version": "1.0", "levelPack": diff --git a/bin/de/bricked/resources/levelpacks/files.txt b/bin/de/bricked/resources/levelpacks/files.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3d1c01444c7423a1c0e5f8c02fa1dc05a6a9550 --- /dev/null +++ b/bin/de/bricked/resources/levelpacks/files.txt @@ -0,0 +1 @@ +default.json Eimer.json \ No newline at end of file diff --git a/bin/de/bricked/resources/textures/powerups/1.png b/bin/de/bricked/resources/textures/powerups/1.png new file mode 100644 index 0000000000000000000000000000000000000000..ce483cc81df758cb80c62f179fd3cde36751b30b Binary files /dev/null and b/bin/de/bricked/resources/textures/powerups/1.png differ diff --git a/bin/de/bricked/ui/LevelPackSelectGUI.fxml b/bin/de/bricked/ui/LevelPackSelectGUI.fxml index 8c2377e952f1e617ac3a35befdeff135589a52d3..886a10633914b5a6ae76fb1feeb0df69f0a3e705 100644 --- a/bin/de/bricked/ui/LevelPackSelectGUI.fxml +++ b/bin/de/bricked/ui/LevelPackSelectGUI.fxml @@ -19,5 +19,10 @@ </font> </Button> <ScrollPane fx:id="pane" layoutX="75.0" layoutY="126.0" maxHeight="549.0" maxWidth="500.0" prefHeight="549.0" prefWidth="500.0" /> + <Button fx:id="downloadLevelpackButton" layoutX="434.0" layoutY="715.0" minHeight="42.0" minWidth="141.0" mnemonicParsing="false" prefHeight="42.0" prefWidth="141.0" text="Download" textAlignment="CENTER"> + <font> + <Font name="System Bold" size="20.0" /> + </font> + </Button> </children> </AnchorPane> diff --git a/src/de/bricked/game/Config.java b/src/de/bricked/game/Config.java index 138f2d65ef3956f88e8cacd20eac02082db5ee84..90091d28c8186c6eb310b3b55464d9ebf98964ed 100644 --- a/src/de/bricked/game/Config.java +++ b/src/de/bricked/game/Config.java @@ -10,5 +10,4 @@ public class Config public final static String JAR_ROOT_DIR = "/de/bricked/resources/"; public final static String JAR_LEVELPACK_SAVEDIR = JAR_ROOT_DIR+"levelpacks/"; public final static String JAR_SOUND_SAVEDIR = JAR_ROOT_DIR + "sounds/"; - -} +} \ No newline at end of file diff --git a/src/de/bricked/game/Game.java b/src/de/bricked/game/Game.java index 9d1680a381db3c87cd448b6976159916bd7cfe0e..85ca1b8f2088a649b9b97cb4f3d18f290a8bf7f0 100644 --- a/src/de/bricked/game/Game.java +++ b/src/de/bricked/game/Game.java @@ -1,9 +1,12 @@ package de.bricked.game; +import java.util.ArrayList; + import de.bricked.game.balls.Ball; import de.bricked.game.board.Board; import de.bricked.game.levels.Level; import de.bricked.game.levels.LevelPack; +import de.bricked.game.powerups.PowerUp; import de.bricked.game.settings.Settings; import de.bricked.ui.LevelController; import javafx.geometry.Point2D; @@ -25,6 +28,8 @@ public class Game private int pointsSinceLastMultiplicatorReset; private int multiplicator; private LevelController levelController; + private ArrayList<PowerUp> movingPowerUps; + private ArrayList<PowerUp> activatedPowerUps; public Game() { @@ -38,6 +43,8 @@ public class Game this.multiplicator = 0; this.pointsSinceLastMultiplicatorReset = 0; this.levelController = null; + this.movingPowerUps = new ArrayList<>(); + this.activatedPowerUps = new ArrayList<>(); } public Settings getSettings() @@ -154,6 +161,26 @@ public class Game public void setLevelController(LevelController levelController) { this.levelController = levelController; + } + + public ArrayList<PowerUp> getMovingPowerUps() + { + return movingPowerUps; + } + + public void setMovingPowerUps(ArrayList<PowerUp> movingPowerUps) + { + this.movingPowerUps = movingPowerUps; + } + + public ArrayList<PowerUp> getActivatedPowerUps() + { + return activatedPowerUps; + } + + public void setActivatedPowerUps(ArrayList<PowerUp> activatedPowerUps) + { + this.activatedPowerUps = activatedPowerUps; } public Point2D reflectBall(HitLocation hitLocation, Point2D direction) diff --git a/src/de/bricked/game/board/Board.java b/src/de/bricked/game/board/Board.java index 59044a15f81745f55b80be4c0bad992e5b70a748..3db453f4e8f248c2d363f8463cc8c64baacb561e 100644 --- a/src/de/bricked/game/board/Board.java +++ b/src/de/bricked/game/board/Board.java @@ -6,6 +6,8 @@ import de.bricked.game.Game; import de.bricked.game.balls.Ball; import de.bricked.game.bricks.Brick; import de.bricked.game.bricks.BrickType; +import de.bricked.game.powerups.ExtraLifePowerUp; +import de.bricked.game.powerups.PowerUp; import de.bricked.ui.LevelController; public class Board @@ -20,7 +22,7 @@ public class Board public Board(Game game) { this.game = game; - + init(); String boardString = game.getLevel().getBoard(); // parse board -> create bricks @@ -31,13 +33,15 @@ public class Board String brickValue = bricksAndPower.substring(0, 1); int powerUp = Integer.parseInt(bricksAndPower.substring(1)); Brick currentBrick = null; - // PowerUp currentPowerUp = null; + PowerUp currentPowerUp = null; // TODO IMPLEMENT POWERUP switch(powerUp) { - case 0: // powerUp = new ExplosiveMegaPowerUp() :D + case 0: + currentPowerUp = null; break; case 1: + currentPowerUp = new ExtraLifePowerUp(); break; case 2: break; @@ -49,35 +53,35 @@ public class Board break; case 6: break; - default: // + default: break; } - + switch(brickValue) { case "N": - currentBrick = new Brick(BrickType.NORMAL); + currentBrick = new Brick(BrickType.NORMAL, currentPowerUp); break; case "A": - currentBrick = new Brick(BrickType.AIR); + currentBrick = new Brick(BrickType.AIR, currentPowerUp); break; case "S": - currentBrick = new Brick(BrickType.SOLID); + currentBrick = new Brick(BrickType.SOLID, currentPowerUp); break; case "H": - currentBrick = new Brick(BrickType.HARD); + currentBrick = new Brick(BrickType.HARD, currentPowerUp); break; case "E": - currentBrick = new Brick(BrickType.EXTRA_HARD); + currentBrick = new Brick(BrickType.EXTRA_HARD, currentPowerUp); break; case "I": - currentBrick = new Brick(BrickType.INVISIBLE); + currentBrick = new Brick(BrickType.INVISIBLE, currentPowerUp); break; case "T": - currentBrick = new Brick(BrickType.TNT); + currentBrick = new Brick(BrickType.TNT, currentPowerUp); break; default: - currentBrick = new Brick(BrickType.AIR); + currentBrick = new Brick(BrickType.AIR, currentPowerUp); break; } @@ -165,7 +169,8 @@ public class Board Brick currentBrick = bricks.get(row).get(col); if(currentBrick.getPowerUp() != null) { - // TODO deploy PowerUp + // deploys powerup + game.getLevelController().addMovingPowerUp(row, col, currentBrick.getPowerUp()); } bricks.get(row).set(col, new Brick(BrickType.TNT)); @@ -205,11 +210,12 @@ public class Board if(hittedBrick.getPowerUp() != null) { - // TODO deploy PowerUp + // deploys powerup + game.getLevelController().addMovingPowerUp(row, col, hittedBrick.getPowerUp()); } points += hittedBrick.getType().getPoints(); - + if(hittedBrick.getType().getPoints() > 0) { game.getLevelController().showAnimatedPoints(row, col, hittedBrick.getType().getPoints()); diff --git a/src/de/bricked/game/powerups/ExtraLifePowerUp.java b/src/de/bricked/game/powerups/ExtraLifePowerUp.java index f49096e66fa78551eae7320e3c575054b2a55f0a..420f47aae2eb5f603182360d2f6fb7e8c1762b48 100644 --- a/src/de/bricked/game/powerups/ExtraLifePowerUp.java +++ b/src/de/bricked/game/powerups/ExtraLifePowerUp.java @@ -4,13 +4,13 @@ package de.bricked.game.powerups; public class ExtraLifePowerUp extends PowerUp { - public ExtraLifePowerUp(int id, int duration) + public ExtraLifePowerUp() { - super(id, duration); + super(PowerUpType.valueOf("EXTRA_LIFE").getId(), -1); } @Override - protected void activate() + public void activate() { } diff --git a/src/de/bricked/game/powerups/PowerUp.java b/src/de/bricked/game/powerups/PowerUp.java index 199e8deb61f99051dc0eed3fbb9daa693b690788..cabfed3675e4e91e1844942d1a08322e3367c542 100644 --- a/src/de/bricked/game/powerups/PowerUp.java +++ b/src/de/bricked/game/powerups/PowerUp.java @@ -4,19 +4,28 @@ public abstract class PowerUp { protected int id; protected int duration; + protected final double speed = 2.0; public PowerUp(int id, int duration) { this.id = id; this.duration = duration; } + + public int getID() + { + return id; + } public boolean isPermanent() { return (duration == -1); - } - - protected abstract void activate(); + } + public double getSpeed() + { + return speed; + } + public abstract void activate(); } \ No newline at end of file diff --git a/src/de/bricked/game/powerups/ball/DecreaseBallSizePowerUp.java b/src/de/bricked/game/powerups/ball/DecreaseBallSizePowerUp.java index 9a46e1231229e2fff1e2e1ab6359023ac322cae6..eb4850dca9a551e60b055bab3b97880fcdc6f10d 100644 --- a/src/de/bricked/game/powerups/ball/DecreaseBallSizePowerUp.java +++ b/src/de/bricked/game/powerups/ball/DecreaseBallSizePowerUp.java @@ -15,7 +15,7 @@ public class DecreaseBallSizePowerUp extends PowerUp } @Override - protected void activate() + public void activate() { } diff --git a/src/de/bricked/game/powerups/ball/IncreaseBallSizePowerUp.java b/src/de/bricked/game/powerups/ball/IncreaseBallSizePowerUp.java index bd872da4eddb4c223112966dfab562eca30fcab8..c40a021896943cff7df9c925a1faec7574539056 100644 --- a/src/de/bricked/game/powerups/ball/IncreaseBallSizePowerUp.java +++ b/src/de/bricked/game/powerups/ball/IncreaseBallSizePowerUp.java @@ -15,7 +15,7 @@ public class IncreaseBallSizePowerUp extends PowerUp } @Override - protected void activate() + public void activate() { } diff --git a/src/de/bricked/game/powerups/paddle/DecreasePaddleSizePowerUp.java b/src/de/bricked/game/powerups/paddle/DecreasePaddleSizePowerUp.java index 653a3aee50dca8502b47d7e12cb71f9f24dc35c6..a62639024677ed32ddb2ebdabdc7295306bbdc2f 100644 --- a/src/de/bricked/game/powerups/paddle/DecreasePaddleSizePowerUp.java +++ b/src/de/bricked/game/powerups/paddle/DecreasePaddleSizePowerUp.java @@ -16,7 +16,7 @@ public class DecreasePaddleSizePowerUp extends PowerUp } @Override - protected void activate() + public void activate() { paddle.setPaddleSize(PaddleSize.getNextSmaller(paddle.getPaddleSize())); } diff --git a/src/de/bricked/game/powerups/paddle/IncreasePaddleSizePowerUp.java b/src/de/bricked/game/powerups/paddle/IncreasePaddleSizePowerUp.java index b4fd878cd8f9f81877f63117473117c645500ac5..75f3c6aaf3b72673928b21820d06d664fbcb775b 100644 --- a/src/de/bricked/game/powerups/paddle/IncreasePaddleSizePowerUp.java +++ b/src/de/bricked/game/powerups/paddle/IncreasePaddleSizePowerUp.java @@ -16,7 +16,7 @@ public class IncreasePaddleSizePowerUp extends PowerUp } @Override - protected void activate() + public void activate() { paddle.setPaddleSize(PaddleSize.getNextBigger(paddle.getPaddleSize())); } diff --git a/src/de/bricked/resources/textures/powerups/1.png b/src/de/bricked/resources/textures/powerups/1.png new file mode 100644 index 0000000000000000000000000000000000000000..ce483cc81df758cb80c62f179fd3cde36751b30b Binary files /dev/null and b/src/de/bricked/resources/textures/powerups/1.png differ diff --git a/src/de/bricked/ui/LevelController.java b/src/de/bricked/ui/LevelController.java index a442a359c07be0ecae50c5997faec2eb6132756a..9125b36abfe53d62d980c3a1ce1150c59298a236 100644 --- a/src/de/bricked/ui/LevelController.java +++ b/src/de/bricked/ui/LevelController.java @@ -2,6 +2,7 @@ package de.bricked.ui; import java.io.IOException; import java.util.ArrayList; +import java.util.Iterator; import java.util.Locale; import java.util.Random; import java.util.ResourceBundle; @@ -15,6 +16,7 @@ import de.bricked.game.board.Board; import de.bricked.game.bricks.Brick; import de.bricked.game.bricks.BrickType; import de.bricked.game.paddle.Paddle; +import de.bricked.game.powerups.PowerUp; import fontAwesome.FontIcon; import fontAwesome.FontIconType; import javafx.animation.AnimationTimer; @@ -91,9 +93,10 @@ public class LevelController private ChangeListener<Number> widthListener; private double oldMousePosition; private static ArrayList<Label> brickLabels; + private ArrayList<Label> movingPowerUps; private void startGame() - { + { anchorPaneGame.heightProperty().removeListener(heightListener); anchorPaneGame.widthProperty().removeListener(widthListener); @@ -120,7 +123,7 @@ public class LevelController this.levelSelectController = levelSelectController; this.game = game; game.setBoard(new Board(game)); - game.setLevelController(this); + game.setLevelController(this); anchorPane.setOnMouseClicked(new EventHandler<MouseEvent>() { @@ -310,6 +313,7 @@ public class LevelController labelFPS.setStyle("-fx-text-fill: #FF0000"); resetMultiplicator(); + movingPowerUps = new ArrayList<>(); gameState = GameState.WAITING; } @@ -481,7 +485,12 @@ public class LevelController } } } - } + + //move powerups + movePowerUps(); + //check timed powerups + checkPowerUps(); + } }; } @@ -737,6 +746,65 @@ public class LevelController parallelTransition.play(); } + + public void addMovingPowerUp(int row, int col, PowerUp powerUp) + { + Label labelPowerUp = new Label(); + labelPowerUp.setStyle("-fx-background-image: url(\"de/bricked/resources/textures/powerups/" + powerUp.getID() + ".png\");" + "-fx-background-position: center center;" + "-fx-background-repeat: no-repeat;" + "-fx-background-size: cover"); + labelPowerUp.setAlignment(Pos.CENTER); + labelPowerUp.setUserData(powerUp); + + labelPowerUp.setPrefWidth(gamePaneWidth / Board.WIDTH); + labelPowerUp.setPrefHeight(gamePaneHeight / Board.HEIGHT); + + anchorPaneGame.getChildren().add(labelPowerUp); + labelPowerUp.setTranslateX(col * (gamePaneWidth/Board.WIDTH)); + labelPowerUp.setTranslateY(row * (gamePaneHeight/Board.HEIGHT)); + + movingPowerUps.add(labelPowerUp); + } + + private void movePowerUps() + { + for(Iterator<Label> iterator = movingPowerUps.iterator(); iterator.hasNext();) + { + Label currentLabel = iterator.next(); + PowerUp currentPowerUp = (PowerUp)currentLabel.getUserData(); + currentLabel.setTranslateY(currentLabel.getTranslateY() + currentPowerUp.getSpeed()); + + //check collision with paddle + Point2D labelPosition = new Point2D(currentLabel.getTranslateX(), currentLabel.getTranslateY()); + Point2D paddlePosition = new Point2D(labelPaddle.getLayoutX() + labelPaddle.getTranslateX(), labelPaddle.getLayoutY() + labelPaddle.getTranslateY()); + + HitLocation hitLocation = game.collides(labelPosition, paddlePosition, paddle.getWidth(), paddle.getHeight(), true); + if(hitLocation != null && (hitLocation.equals(HitLocation.PADDLE) || hitLocation.equals(HitLocation.CORNER))) + { + //TODO activate method + //TODO check if timed + Logger.log(LogLevel.DEBUG, "Collected PowerUp with ID = " + currentPowerUp.getID()); + currentPowerUp.activate(); + anchorPaneGame.getChildren().remove(currentLabel); + iterator.remove(); + continue; + } + + if(currentLabel.getTranslateY() + currentLabel.getHeight() >= gamePaneHeight) + { + //power up reached bottom wall + anchorPaneGame.getChildren().remove(currentLabel); + iterator.remove(); + } + } + } + + private void checkPowerUps() + { + //TODO check timed powerups +// for(Iterator<PowerUp> iterator = game.getActivatedPowerUps().iterator(); iterator.hasNext();) +// { +// ) +// } + } public void showLabelFPS(boolean value) { @@ -757,7 +825,7 @@ public class LevelController } public void back() - { + { if(timer != null) { timer.stop(); @@ -768,7 +836,9 @@ public class LevelController game.resetMultiplicator(); game.resetPointsSinceLastMultiplicatorReset(); game.setBoard(null); - game.setLevelController(null); + game.setLevelController(null); + game.setMovingPowerUps(new ArrayList<>()); + game.setActivatedPowerUps(new ArrayList<>()); anchorPaneGame.requestFocus(); }