Merge remote-tracking branch 'origin/master'

master
Chara1236 2022-06-19 21:30:31 -04:00
commit 99439bd4b2
9 changed files with 23 additions and 14 deletions

View File

@ -80,4 +80,4 @@ public class GameFrame extends JFrame{
this.setLocationRelativeTo(null);//set window in middle of screen this.setLocationRelativeTo(null);//set window in middle of screen
} }
} }

View File

@ -602,4 +602,4 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
return flippedImage; return flippedImage;
} }
} }

View File

@ -116,4 +116,4 @@ public class GenericSprite extends Rectangle implements Serializable {
} }
} }

View File

@ -10,4 +10,4 @@ class Main {
new GameFrame(); new GameFrame();
} }
} }

View File

@ -204,4 +204,4 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{
} }
} }

View File

@ -101,4 +101,4 @@ public class NonPlayer extends GenericSprite implements Serializable {
return 0; return 0;
} }
} }
} }

View File

@ -40,6 +40,8 @@ public class Player extends GenericSprite {
// sA[2] is -x, y // sA[2] is -x, y
// sA[3] is x, y // sA[3] is x, y
public BufferedImageWrapper[][][] spriteArray; public BufferedImageWrapper[][][] spriteArray;
public boolean leftClickPlacedSteel;
public Player(int x, int y, BufferedImageWrapper[][][] sprites) throws UnsupportedAudioFileException, LineUnavailableException, IOException { public Player(int x, int y, BufferedImageWrapper[][][] sprites) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
super(x, y, PLAYER_HEIGHT, PLAYER_WIDTH); super(x, y, PLAYER_HEIGHT, PLAYER_WIDTH);
// jump = new Sound("sound/jump.wav"); // jump = new Sound("sound/jump.wav");
@ -306,13 +308,17 @@ public class Player extends GenericSprite {
mouseX = e.getX(); mouseX = e.getX();
mouseY = e.getY(); mouseY = e.getY();
if(e.getButton()==MouseEvent.BUTTON1) { if(e.getButton()==MouseEvent.BUTTON1) {
leftMouseDown = true; int x = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
int y = (mouseY / Tile.length);
if (holdingSteel && ((GameFrame.game.map[x][y] == null || GameFrame.game.map[x][y].replaceAble) && canPlaceSteel)) { if (holdingSteel && ((GameFrame.game.map[x][y] == null || GameFrame.game.map[x][y].replaceAble) && canPlaceSteel)) {
Tile temp = GameFrame.game.map[x][y]; Tile temp = GameFrame.game.map[x][y];
GameFrame.game.map[x][y] = new SingleTile(x * Tile.length - (GamePanel.GAME_WIDTH / 2), y * Tile.length, new BufferedImageWrapper(("img/tiles/boxes/steel.png"))); GameFrame.game.map[x][y] = new SingleTile(x * Tile.length - (GamePanel.GAME_WIDTH / 2), y * Tile.length, new BufferedImageWrapper(("img/tiles/boxes/steel.png")));
GameFrame.game.map[x][y].movable = true; GameFrame.game.map[x][y].movable = true;
GameFrame.game.map[x][y].previousBlock = temp; GameFrame.game.map[x][y].previousBlock = temp;
holdingSteel = false; holdingSteel = false;
leftClickPlacedSteel = true;
} else {
leftMouseDown = true;
} }
} }
if(e.getButton()==MouseEvent.BUTTON3) { if(e.getButton()==MouseEvent.BUTTON3) {
@ -414,10 +420,14 @@ public class Player extends GenericSprite {
mouseY = e.getY(); mouseY = e.getY();
if(e.getButton()==MouseEvent.BUTTON1) { if(e.getButton()==MouseEvent.BUTTON1) {
leftMouseDown = false; leftMouseDown = false;
if (GameFrame.game.bombs.size() < 2 && LevelManager.bombs>0 && !holdingSteel) { if (leftClickPlacedSteel) {
LevelManager.bombs--; leftClickPlacedSteel = false;
GameFrame.game.bombs.add(new StickyBomb(GameFrame.game.player.x + GameFrame.game.camera.x + WIDTH/2, GameFrame.game.player.y+HEIGHT/2, } else {
(mouseX - GameFrame.game.player.x) / 20, (mouseY - GameFrame.game.player.y) / 10, GameFrame.game.bomb, GameFrame.game.explosionArray)); if (GameFrame.game.bombs.size() < 2 && LevelManager.bombs > 0 && !holdingSteel) {
LevelManager.bombs--;
GameFrame.game.bombs.add(new StickyBomb(GameFrame.game.player.x + GameFrame.game.camera.x + WIDTH / 2, GameFrame.game.player.y + HEIGHT / 2,
(mouseX - GameFrame.game.player.x) / 20, (mouseY - GameFrame.game.player.y) / 10, GameFrame.game.bomb, GameFrame.game.explosionArray));
}
} }
} }
if(e.getButton()==MouseEvent.BUTTON3){ if(e.getButton()==MouseEvent.BUTTON3){
@ -451,4 +461,4 @@ public class Player extends GenericSprite {
} }
//public int BfsDis() //public int BfsDis()
} }

View File

@ -142,4 +142,4 @@ public class SettingPanel extends MenuPanel {
currentBox = UtilityFunction.processBox(e, currentBox, textBoxArray); currentBox = UtilityFunction.processBox(e, currentBox, textBoxArray);
} }
} }
} }

View File

@ -15,6 +15,5 @@ public class WallSign extends TextBox implements Serializable {
newX -= GameFrame.game.camera.x; newX -= GameFrame.game.camera.x;
super.draw(g, new Color(0, 0, 0, 0), textColor); super.draw(g, new Color(0, 0, 0, 0), textColor);
newX = oldX; newX = oldX;
System.out.println();
} }
} }