diff --git a/src/BufferedImageWrapper.java b/src/BufferedImageWrapper.java index dfc96aa..9d7aae4 100644 --- a/src/BufferedImageWrapper.java +++ b/src/BufferedImageWrapper.java @@ -57,7 +57,7 @@ public class BufferedImageWrapper implements Serializable { // custom writeObject method that allows writing an otherwise unserializable method to disk @Serial - private void writeObject(ObjectOutputStream out) throws IOException { + public void writeObject(ObjectOutputStream out) throws IOException { // save whether the image is flipped out.writeObject(flipImage); // if the imageString is present, write that to disk to prevent excessive disk writes @@ -70,7 +70,7 @@ public class BufferedImageWrapper implements Serializable { // custom readObject method that allows reading an otherwise unserializable method from disk @Serial - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { Object o; // read whether the image is flipped or not flipImage = (Boolean)in.readObject(); diff --git a/src/FireBall.java b/src/FireBall.java index b0213f9..02fe3ae 100644 --- a/src/FireBall.java +++ b/src/FireBall.java @@ -8,11 +8,11 @@ import java.io.IOException; public class FireBall extends GenericSprite{ public String spritePath; - private int realX; + public int realX; public boolean dead; - private int lifeSpan; + public int lifeSpan; // called every time GamePanel.updateShootingBlock is called public FireBall(int x, int y, int xv, int yv, String dir,int height, int width) { diff --git a/src/Player.java b/src/Player.java index f29a37b..94cdd7e 100644 --- a/src/Player.java +++ b/src/Player.java @@ -19,7 +19,7 @@ public class Player extends GenericSprite { public int lastXDirection, lastYDirection, lastFrame; public boolean alive; - private transient Sound jump = new Sound("sound/jump.wav"); + public transient Sound jump = new Sound("sound/jump.wav"); public static int mouseX; public static int mouseY; @@ -31,7 +31,7 @@ public class Player extends GenericSprite { boolean canPlaceSteel; - private int pickupDelay = 5; + public int pickupDelay = 5; // sA[0] is -x, -y // sA[1] is x, -y diff --git a/src/SingleTile.java b/src/SingleTile.java index 70ce65a..a0590ef 100644 --- a/src/SingleTile.java +++ b/src/SingleTile.java @@ -1,3 +1,5 @@ +// Eric Li, Charlie Zhao, ICS4U, Completed 6/20/2022 +// SingleTile class adds sprites to the tile class import java.awt.*; import java.io.Serializable; @@ -5,13 +7,16 @@ public class SingleTile extends Tile implements Serializable { public BufferedImageWrapper tileImage; public SingleTile(int x, int y, BufferedImageWrapper tileImage) throws SpriteException { + //Creates tile super(x, y); - + //Sets sprite for the tile if (tileImage.image.getWidth() != tileImage.image.getHeight()) { throw new SpriteException(); } this.tileImage = tileImage; } + + //Draws the tile on the screen public void draw(Graphics g){ g.drawImage(tileImage.image, x-GameFrame.game.camera.x, y, length, length, null); } diff --git a/src/SoundWrapper.java b/src/SoundWrapper.java index db89c74..a2f48db 100644 --- a/src/SoundWrapper.java +++ b/src/SoundWrapper.java @@ -21,13 +21,13 @@ public class SoundWrapper implements Serializable { public SoundWrapper() {} @Serial - private void writeObject(ObjectOutputStream out) throws IOException { + public void writeObject(ObjectOutputStream out) throws IOException { // write location of .wav file (soundString) out.writeObject(soundString); } @Serial - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException, UnsupportedAudioFileException, LineUnavailableException { + public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException, UnsupportedAudioFileException, LineUnavailableException { // read .wav file located at soundString Object o; o = in.readObject(); diff --git a/src/StickyBomb.java b/src/StickyBomb.java index 3e36db7..3fe299e 100644 --- a/src/StickyBomb.java +++ b/src/StickyBomb.java @@ -45,7 +45,7 @@ public class StickyBomb extends GenericSprite implements Serializable { - //Updates the realX position of the bomb, rather than where it is drawn on the screen. + //Updates the realX position of the bomb, which is what is drawn on the screen public void update(){ realX = x - GameFrame.game.camera.x; } @@ -214,12 +214,14 @@ public class StickyBomb extends GenericSprite implements Serializable { + //Draws the bomb public void draw(Graphics g) throws UnsupportedAudioFileException, LineUnavailableException, IOException { if (explosionCounter >= 2) { explosionPixel += 1; explosionCounter -= 2; } + //If the bomb is alive, don't animate explosion, else do. if(alive) { g.drawImage(sprite.image, x - GameFrame.game.camera.x - (spriteLength-length)/2, y - (spriteLength-length)/2, spriteLength, spriteLength, null); //g.drawRect(x-GameFrame.game.camera.x,y,length,length); diff --git a/src/Tile.java b/src/Tile.java index 60dca6d..2bc7ef3 100644 --- a/src/Tile.java +++ b/src/Tile.java @@ -1,3 +1,5 @@ +// Eric Li, Charlie Zhao, ICS4U, Completed 6/20/2022 +// Tile class allows the creation of tiles which will serve as the playing field of the platformer import java.awt.*; import java.io.Serializable; @@ -27,6 +29,7 @@ public class Tile implements Serializable { public Tile(int x, int y){ + //Sets default state of tile isFinish = false; collision = true; kills = false; @@ -39,10 +42,13 @@ public class Tile implements Serializable { previousBlock = null; shootingDir = "none"; } + + //Updates the real x position of the bomb, what is drawn on the screen public void update(){ realX = x-GameFrame.game.camera.x; } + //Draws the tile on the screen public void draw(Graphics g){ g.setColor(Color.black); g.fillRect(x-GameFrame.game.camera.x, y, length, length);