Merge remote-tracking branch 'origin/master'
commit
32a503a59e
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -339,7 +339,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
}
|
||||
// draw bomb counter (bomb image and amount of bombs remaining)
|
||||
g.drawImage(bomb.image,20,20,35,35,null);
|
||||
g.drawString("X"+LevelManager.bombs+" Sticky bombs",60,40);
|
||||
g.drawString("X"+LevelManager.bombs,60,40);
|
||||
if (isPaused) {
|
||||
// cover background with translucent rectangle
|
||||
g.setColor(new Color(255, 255, 255, 100));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue