diff --git a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.java b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.java index c181645..521bded 100644 --- a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.java +++ b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.java @@ -41,9 +41,6 @@ public class GamePlayManager { /** Flag, if the bubble movement is froze */ public boolean movementFroze; - private int backgroundMusic; - private int harpoonSound; - /** * Create the manager handling the gameplay. * @@ -66,7 +63,7 @@ public class GamePlayManager { * @param easyDifficulty the game difficulty */ private void initializeGame(boolean easyDifficulty){ - //backgroundMusic = gameView.playSound("backgroundMusic.wav", true); + gameView.playSound("backgroundMusic.wav", true); gameObjectManager.clearAll(); levelManager = new LevelManager(easyDifficulty); try { @@ -76,7 +73,6 @@ public class GamePlayManager { System.exit(-1); } player = new Player(level); - player.score = 1000000; gameObjectManager.getPlayerObject().setGamePlayManager(this); } @@ -99,12 +95,16 @@ public class GamePlayManager { * Loose a life and remove all bubbles */ public void looseLife(){ - player.lives--; - gameObjectManager.getLivesLabel().setLifeCount(player.lives); - gameObjectManager.getBubbles().clear(); - specialBubblePresent = false; - spawnBubbles = true; - gameObjectManager.getGameOverlay().flashScreen(Color.red,100); + if(player.lives==0){ + handleGameEnded("You lost the game.\nYour score: "+player.score); + }else { + player.lives--; + gameObjectManager.getLivesLabel().setLifeCount(player.lives); + gameObjectManager.getBubbles().clear(); + specialBubblePresent = false; + spawnBubbles = true; + gameObjectManager.getGameOverlay().flashScreen(Color.red, 100); + } } /** @@ -115,14 +115,23 @@ public class GamePlayManager { level = levelManager.getNextLevel(); initializeLevel(); } catch (LevelManager.NoMoreLevelsAvailableException e) { - gameView.stopAllSounds(); - gameView.showEndScreen("You won!"); - boolean easyDifficulty = gameView.showSimpleStartScreen("Super Pang World","Start the game"); - initializeGame(easyDifficulty); - initializeLevel(); + handleGameEnded("You won the game.\nYour score: "+player.score); } } + /** + * End the game and show exit/restart screen. + * + * @param text text to display + */ + private void handleGameEnded(String text){ + gameView.stopAllSounds(); + gameView.showEndScreen(text); + boolean easyDifficulty = gameView.showSimpleStartScreen("Super Pang World","Start the game"); + initializeGame(easyDifficulty); + initializeLevel(); + } + /** * Update all HUD elements */ diff --git a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.java b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.java index 03e6f3c..840265c 100644 --- a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.java +++ b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.java @@ -19,6 +19,8 @@ public class Harpoon extends CollidingGameObject implements MovingGameObject { "k kkk k\n"+ "k kkk k\n"; + private final String harpoonRope; + private int sound; /** @@ -35,14 +37,39 @@ public class Harpoon extends CollidingGameObject implements MovingGameObject { height = (int) (5 * size); rotation = 0; getPosition().setTo(300,300); - this.hitBox.width = width; + this.hitBox.width = width - 2; this.hitBox.height = (int) (440 - position.y); sound = gameView.playSound("harpoon.wav",true); + + harpoonRope = generateRope(); + } + + private String generateRope(){ + + int pre = 3; + int post = 3; + boolean right = true; + String rope = ""; + + for(int i=0;i<100;i++){ + rope += " ".repeat(pre) + "k" + " ".repeat(post)+"\n"; + if(right){ + pre++; + post--; + }else{ + pre--; + post++; + } + if(post==0 || pre==0){ + right = !right; + } + } + return rope; } @Override protected void updateHitBoxPosition() { - hitBox.x = (int) (position.x); + hitBox.x = (int) (position.x) + 1; hitBox.y = (int) (position.y); hitBox.height = (int) (440 - position.y); } @@ -58,7 +85,7 @@ public class Harpoon extends CollidingGameObject implements MovingGameObject { @Override public void addToCanvas(){ gameView.addBlockImageToCanvas(HARPOON, getPosition().x, getPosition().y,size, rotation); - gameView.addRectangleToCanvas(position.x + (width/2.0) - 2,position.y + height, 4,440 - position.y,1,true,Color.lightGray); + gameView.addBlockImageToCanvas(harpoonRope, position.x + (width/2.0) - 7,position.y + height,2,0); } /** diff --git a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.java b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.java index 1cce494..5f37ad3 100644 --- a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.java +++ b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.java @@ -52,7 +52,6 @@ public class HexagonalBubble extends Bubble { @Override public void addToCanvas() { gameView.addImageToCanvas("hexagon.png",position.x,position.y,size,rotation); - gameView.addRectangleToCanvas(hitBox.x,hitBox.y,hitBox.width,hitBox.height,1,false, Color.GREEN); } @Override diff --git a/out/artifacts/Programmieren_2_jar/Programmieren 2.jar b/out/artifacts/Programmieren_2_jar/Programmieren 2.jar index 97dcdae..21c0f64 100644 Binary files a/out/artifacts/Programmieren_2_jar/Programmieren 2.jar and b/out/artifacts/Programmieren_2_jar/Programmieren 2.jar differ diff --git a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.class b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.class index be29d67..1df1054 100644 Binary files a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.class and b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/game/managers/GamePlayManager.class differ diff --git a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/immovable/LivesLabel.class b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/immovable/LivesLabel.class index 2891f16..4d0a9d3 100644 Binary files a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/immovable/LivesLabel.class and b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/immovable/LivesLabel.class differ diff --git a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.class b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.class index f35b543..2d2066e 100644 Binary files a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.class and b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/Harpoon.class differ diff --git a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.class b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.class index b1850ef..b4dd29f 100644 Binary files a/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.class and b/out/production/SuperPangWorld/de/thdeg/greiner/superpangworld/graphics/moveable/HexagonalBubble.class differ diff --git a/out/production/SuperPangWorld/resources/backgroundMusic.wav b/out/production/SuperPangWorld/resources/backgroundMusic.wav index 00b5296..b7685cf 100644 Binary files a/out/production/SuperPangWorld/resources/backgroundMusic.wav and b/out/production/SuperPangWorld/resources/backgroundMusic.wav differ