Allow left click to place steel
parent
bbadd99a6f
commit
06e81d4646
|
@ -40,6 +40,8 @@ public class Player extends GenericSprite {
|
|||
// sA[2] is -x, y
|
||||
// sA[3] is x, y
|
||||
public BufferedImageWrapper[][][] spriteArray;
|
||||
public boolean leftClickPlacedSteel;
|
||||
|
||||
public Player(int x, int y, BufferedImageWrapper[][][] sprites) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
||||
super(x, y, PLAYER_HEIGHT, PLAYER_WIDTH);
|
||||
// jump = new Sound("sound/jump.wav");
|
||||
|
@ -306,13 +308,17 @@ public class Player extends GenericSprite {
|
|||
mouseX = e.getX();
|
||||
mouseY = e.getY();
|
||||
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)) {
|
||||
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].movable = true;
|
||||
GameFrame.game.map[x][y].previousBlock = temp;
|
||||
holdingSteel = false;
|
||||
leftClickPlacedSteel = true;
|
||||
} else {
|
||||
leftMouseDown = true;
|
||||
}
|
||||
}
|
||||
if(e.getButton()==MouseEvent.BUTTON3) {
|
||||
|
@ -414,12 +420,16 @@ public class Player extends GenericSprite {
|
|||
mouseY = e.getY();
|
||||
if(e.getButton()==MouseEvent.BUTTON1) {
|
||||
leftMouseDown = false;
|
||||
if (leftClickPlacedSteel) {
|
||||
leftClickPlacedSteel = false;
|
||||
} else {
|
||||
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){
|
||||
rightMouseDown = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue