diff --git a/sound/pen-2.wav b/sound/pen-2.wav index 12e6d44..2246ad2 100644 Binary files a/sound/pen-2.wav and b/sound/pen-2.wav differ diff --git a/src/LevelManager.java b/src/LevelManager.java index d24d503..07f4d7f 100644 --- a/src/LevelManager.java +++ b/src/LevelManager.java @@ -45,7 +45,7 @@ public class LevelManager implements Serializable { xSpawn = -1100; ySpawn = 460; filePath = "saves/Level4.txt"; - bombs = 5; + bombs = 6; } else if(level == 5){ //-1100/460 xSpawn = -1100; diff --git a/src/Main.java b/src/Main.java index bc79c25..1cf7145 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,13 +1,23 @@ // Eric Li, Charlie Zhao, ICS4U, Finished 5/30/2022 -/* Main class starts the game -All it does is run the constructor in GameFrame class +/* Main class starts the game, suppresses all output to console +This also runs the constructor in GameFrame class This is a common technique among coders to keep things organized (and handy when coding in repl.it since we're forced to call a class Main, which isn't always very descriptive) -*/ +*/ + +import java.io.OutputStream; +import java.io.PrintStream; class Main { public static void main(String[] args) { + // suppresses output to console + System.setOut(new PrintStream(new OutputStream() { + public void write(int b) { + // does nothing + } + })); + new GameFrame(); } diff --git a/src/MenuPanel.java b/src/MenuPanel.java index 3864bb8..84a9b0d 100644 --- a/src/MenuPanel.java +++ b/src/MenuPanel.java @@ -182,6 +182,9 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{ // if the user presses "New Game", reset GamePanel and navigate to it if (textBoxArray.get(currentBox).id.equals("game-start")) { try { + // temporary variable so was not declared earlier + // save middleware array to re-add after game is created again + ArrayList oldMiddlewareArray = (ArrayList)GameFrame.game.middlewareArray.clone(); // remove the old GamePanel from the CardLayout CameraPanel GameFrame.main.remove(GameFrame.game); // stop the run() while loop, effectively killing the thread @@ -192,6 +195,8 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{ // reset the tile map to prevent race conditions GameFrame.game.map = new Tile[1000][18]; GameFrame.game = new GamePanel(GameFrame.main); //run GamePanel constructor + // readd middleware array + GameFrame.game.middlewareArray = oldMiddlewareArray; // make it so that the game can be resumed if the player leaves GameFrame.game.isContinue = true; textBoxArray.add(continueGame); diff --git a/src/Player.java b/src/Player.java index 94cdd7e..76cbe0d 100644 --- a/src/Player.java +++ b/src/Player.java @@ -203,7 +203,7 @@ public class Player extends GenericSprite { if(GameFrame.game.map[x][y]!=null&&!GameFrame.game.map[x][y].replaceAble){canPlaceSteel = false; return;} //If you can't reach an area because of blocks in the way, you can't place. - if(!canReach(xx,yy)){canPlaceSteel = false; return;}; + if(!canReach(xx,yy)){canPlaceSteel = false;} } @@ -220,7 +220,7 @@ public class Player extends GenericSprite { } //Stops player from glitching into corner if(canUpdate(xVelocity, 0)&&canUpdate(0, yVelocity)&&!canUpdate(xVelocity, yVelocity)){ - GameFrame.game.camera.x += -Math.signum(xVelocity); + GameFrame.game.camera.x -= Math.signum(xVelocity); } //Prevents player from passing tiles in the x-direction @@ -434,16 +434,10 @@ public class Player extends GenericSprite { yy.add(newY); } } - } catch (Exception e) { - - } + } catch (Exception ignored) {} } } - if (dis[x][y] <= 6) { - return true; - } - - return false; + return dis[x][y] <= 6; }catch(Exception e){ return false; } diff --git a/tips and tricks.txt b/tips and tricks.txt index 4dac2f5..a7b71d8 100644 --- a/tips and tricks.txt +++ b/tips and tricks.txt @@ -1,3 +1,4 @@ Press P to skip to the next level. Delete local/game_state if you bound the wrong controls and are not having a good time. -Use bombs sparingly. \ No newline at end of file +Use bombs sparingly. +The game is fairly computationally expensive, so there may be five-second pauses when the game is rendering more tiles; if this happens, don't quit the game. \ No newline at end of file