@Override public void update() { // TODO Auto-generated method stub if (!canBuy) getShell(); if (canBuy && !bought) { if (InputUtility.isMouseLeftDown()) { this.x = InputUtility.getMouseX() - 75 / 2; this.y = InputUtility.getMouseY() - 75 / 2; this.z = Integer.MAX_VALUE; } if (!InputUtility.isMouseLeftDown() && InputUtility.isMouseLeftDownUp()) { if (GameLogic.playingArea.canBePlaced(InputUtility.getMouseX(), InputUtility.getMouseY())) { this.x = GameLogic.playingArea.placedX(InputUtility.getMouseX()); this.y = GameLogic.playingArea.placedY(InputUtility.getMouseY()); this.column = (x - 175) / 75; GameLogic.playingArea.placed((y - 125) / 75, column); this.bought = true; GameLogic.newShell = true; } else { this.x = defaultX; this.y = defaultY; this.canBuy = false; this.z = 0; } } } if (bought) { if (hp == 0) { GameLogic.playingArea.dead((y - 125) / 75, (x - 175) / 75); dead = true; } } }
public void getShell() { if (InputUtility.isMouseLeftDownTrigger()) { if (defaultX <= InputUtility.getMouseX() && defaultX + 75 >= InputUtility.getMouseX()) { if (defaultY <= InputUtility.getMouseY() && defaultY + 75 >= InputUtility.getMouseY()) { canBuy = true; InputUtility.setMouseLeftDownTrigger(false); } } } else canBuy = false; }