diff --git a/saves/Level1.txt b/saves/Level1.txt index f7ee114..f7da3df 100644 --- a/saves/Level1.txt +++ b/saves/Level1.txt @@ -1,18 +1,18 @@ -wwwwwwwwwwwwwwwwwe -sssssssssssssssssd -sssssssssssssssssd 1 -sssssssssssssssssd -sssssssssssssssssd -sssssssssssssssssd 1 1lllllllll1 1 1 -sssssssssssssssssd 1 -sssssssssssssssssd - qe qe - u qwe ad ! ad qre - h k a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad -sssssssssssssssssd m zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad -sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad -sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad -sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad -sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad -sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwek vvvvvvvvvvvvvvvvvvvvv + ad -ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3 \ No newline at end of file +wwwwwwwwwwwwwwwwwe qwwwwwwwwwwwwwwwwe +wwwwwwwwwwwwwwe +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd assssssssssssssssd +ssssssssssssssd +sssssssssssssssssd asssssssssssssssstwwwwwwwwwwwe +ssssssssssssssd +sssssssssssssssssd zxxxxxxxxxxxxxxxxxxxxxxxxxxxftwwwwwwe qe +ssssssssssssssd +sssssssssssssssssd bb zxxxxxxxcooad h +ssssssssssssssd +sssssssssssssssssd qe q e bb ad +ssssssssssssssd +sssssssssssssssssd ad qwwwrlllte bb ad +ssssssssssssssd +sssssssssssssssssd ad asssssssste bb ad +ssssssssssssssd +sssssssssssssssssd ad ! qwrssssssssstwwwe bb ad h +ssssssssssssssd +ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrtwwwwwwwwwwwwwwwwrsssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwd diff --git a/sound/grass.wav b/sound/grass.wav new file mode 100644 index 0000000..73f2074 Binary files /dev/null and b/sound/grass.wav differ diff --git a/src/GamePanel.java b/src/GamePanel.java index 2bd6789..07f9a01 100644 --- a/src/GamePanel.java +++ b/src/GamePanel.java @@ -350,7 +350,6 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ // throw new RuntimeException(e); } } - g.drawString(player.xVelocity+"",400,400); } //call the move methods in other classes to update positions @@ -424,6 +423,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ } else { LevelManager.bombs = bombCount; } + try { + player.resetNoSound(); + } catch (IOException e) { + throw new RuntimeException(e); + } //the CPU runs our game code too quickly - we need to slow it down! The following lines of code "force" the computer to get stuck in a loop for short intervals between calling other methods to update the screen. long lastTime = System.nanoTime(); double amountOfTicks = 60; @@ -451,7 +455,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ } checkCollision(); updateEnemy(); - if(fireballCounter<0){fireballCounter = 100;} + if(fireballCounter<0){fireballCounter = 200;} fireballCounter--; if(fireballCounter == 0){ updateShootingBlock(); @@ -541,7 +545,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ waitForDialogue = false; } } else { - player.keyPressed(e); + try { + player.keyPressed(e); + } catch (IOException ex) { + throw new RuntimeException(ex); + } } } diff --git a/src/GenericSprite.java b/src/GenericSprite.java index edc7504..d00d970 100644 --- a/src/GenericSprite.java +++ b/src/GenericSprite.java @@ -40,7 +40,7 @@ public class GenericSprite extends Rectangle implements Serializable { //called from GamePanel when any keyboard input is detected //updates the direction of the ball based on user input //if the keyboard input isn't any of the options (d, a, w, s), then nothing happens - public void keyPressed(KeyEvent e){ + public void keyPressed(KeyEvent e) throws IOException { } diff --git a/src/LevelManager.java b/src/LevelManager.java index bfbeaba..4594cd8 100644 --- a/src/LevelManager.java +++ b/src/LevelManager.java @@ -8,8 +8,8 @@ import java.util.Arrays; public class LevelManager implements Serializable { public static int level = 1; - public static int xSpawn = 0; - public static int ySpawn = 600; + public static int xSpawn = -400; + public static int ySpawn = 500; public static String filePath; @@ -21,8 +21,9 @@ public class LevelManager implements Serializable { GameFrame.game.player.xVelocity = 0; LevelManager.level = level; if(level == 1){ - xSpawn = 0; - ySpawn = 300; + //-400/500 + xSpawn = -400; + ySpawn = 500; filePath = "saves/Level1.txt"; bombs = 99999; } else if(level == 2){ diff --git a/src/Player.java b/src/Player.java index dab9c4d..3c5ae4d 100644 --- a/src/Player.java +++ b/src/Player.java @@ -61,7 +61,7 @@ public class Player extends GenericSprite { // moves paddle when key is pressed - public void keyPressed(KeyEvent e) { + public void keyPressed(KeyEvent e) throws IOException { if(e.getKeyCode() == KeyEvent.VK_D){ rightPressed = true; } @@ -74,6 +74,9 @@ public class Player extends GenericSprite { if(e.getKeyCode() == KeyEvent.VK_S){ downPressed = true; } + if(e.getKeyCode() == KeyEvent.VK_R){ + resetNoSound(); + } } // stops moving paddle when key is released @@ -105,6 +108,9 @@ public class Player extends GenericSprite { // calls parent public boolean canUpdate(double x, double y) throws UnsupportedAudioFileException, LineUnavailableException, IOException { + if(this.y+y<=-HEIGHT){ + return false; + } boolean canUpdate = true; int lowX = Math.max(0, ((GameFrame.game.camera.x+GamePanel.GAME_WIDTH)/Tile.length)-4); int highX = Math.min(lowX + 8, GameFrame.game.map.length); @@ -129,6 +135,7 @@ public class Player extends GenericSprite { } } } + return canUpdate; } @@ -186,6 +193,7 @@ public class Player extends GenericSprite { public void move() throws IOException, UnsupportedAudioFileException, LineUnavailableException { // mouseX = MouseInfo.getPointerInfo().getLocation().x; // mouseY = MouseInfo.getPointerInfo().getLocation().y; + pickupDelay = Math.max(0,pickupDelay - 1); int Tilex = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length; int Tiley = (mouseY / Tile.length); @@ -279,6 +287,7 @@ public class Player extends GenericSprite { reset(); } capSpeed(); + } public void reset() throws UnsupportedAudioFileException, LineUnavailableException, IOException { @@ -288,7 +297,7 @@ public class Player extends GenericSprite { y = LevelManager.ySpawn; holdingSteel = false; } - public void resetNoSound() throws UnsupportedAudioFileException, LineUnavailableException, IOException { + public void resetNoSound() throws IOException { LevelManager.setLevel(LevelManager.level, true); GameFrame.game.camera.x = LevelManager.xSpawn; y = LevelManager.ySpawn; diff --git a/src/SoundWrapper.java b/src/SoundWrapper.java index 50f428f..ac1eed8 100644 --- a/src/SoundWrapper.java +++ b/src/SoundWrapper.java @@ -1,11 +1,29 @@ import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; import java.io.*; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.swing.*; public class SoundWrapper implements Serializable { transient public Sound sound; public String soundString; + public static Sound grass; + + static { + try { + grass = new Sound("sound/grass.wav"); + } catch (UnsupportedAudioFileException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (LineUnavailableException e) { + throw new RuntimeException(e); + } + } + // please note that not as many constructors were implemented as BufferedImage, as this class was created before most sounds were added; // as such, backwards compatibility was not needed public SoundWrapper(String soundLocation) throws UnsupportedAudioFileException, LineUnavailableException, IOException { @@ -37,4 +55,5 @@ public class SoundWrapper implements Serializable { } sound.start(); } + }