Merge remote-tracking branch 'origin/master'

master
Chara1236 2022-06-20 22:11:11 -04:00
commit f844f0a112
6 changed files with 25 additions and 15 deletions

Binary file not shown.

View File

@ -45,7 +45,7 @@ public class LevelManager implements Serializable {
xSpawn = -1100; xSpawn = -1100;
ySpawn = 460; ySpawn = 460;
filePath = "saves/Level4.txt"; filePath = "saves/Level4.txt";
bombs = 5; bombs = 6;
} else if(level == 5){ } else if(level == 5){
//-1100/460 //-1100/460
xSpawn = -1100; xSpawn = -1100;

View File

@ -1,13 +1,23 @@
// Eric Li, Charlie Zhao, ICS4U, Finished 5/30/2022 // Eric Li, Charlie Zhao, ICS4U, Finished 5/30/2022
/* Main class starts the game /* Main class starts the game, suppresses all output to console
All it does is run the constructor in GameFrame class 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) 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 { class Main {
public static void main(String[] args) { 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(); new GameFrame();
} }

View File

@ -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 the user presses "New Game", reset GamePanel and navigate to it
if (textBoxArray.get(currentBox).id.equals("game-start")) { if (textBoxArray.get(currentBox).id.equals("game-start")) {
try { try {
// temporary variable so was not declared earlier
// save middleware array to re-add after game is created again
ArrayList<Middleware> oldMiddlewareArray = (ArrayList<Middleware>)GameFrame.game.middlewareArray.clone();
// remove the old GamePanel from the CardLayout CameraPanel // remove the old GamePanel from the CardLayout CameraPanel
GameFrame.main.remove(GameFrame.game); GameFrame.main.remove(GameFrame.game);
// stop the run() while loop, effectively killing the thread // 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 // reset the tile map to prevent race conditions
GameFrame.game.map = new Tile[1000][18]; GameFrame.game.map = new Tile[1000][18];
GameFrame.game = new GamePanel(GameFrame.main); //run GamePanel constructor 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 // make it so that the game can be resumed if the player leaves
GameFrame.game.isContinue = true; GameFrame.game.isContinue = true;
textBoxArray.add(continueGame); textBoxArray.add(continueGame);

View File

@ -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(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 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 //Stops player from glitching into corner
if(canUpdate(xVelocity, 0)&&canUpdate(0, yVelocity)&&!canUpdate(xVelocity, yVelocity)){ 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 //Prevents player from passing tiles in the x-direction
@ -434,16 +434,10 @@ public class Player extends GenericSprite {
yy.add(newY); yy.add(newY);
} }
} }
} catch (Exception e) { } catch (Exception ignored) {}
}
} }
} }
if (dis[x][y] <= 6) { return dis[x][y] <= 6;
return true;
}
return false;
}catch(Exception e){ }catch(Exception e){
return false; return false;
} }

View File

@ -1,3 +1,4 @@
Press P to skip to the next level. 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. Delete local/game_state if you bound the wrong controls and are not having a good time.
Use bombs sparingly. 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.