private void attackMoveSelected(int x, int y) { attackMoveClicked = false; GameSprite target = level.getSpriteAt(x, y); for (GameSprite sprite : selected) { if (target == null) sprite.goTo(x, y, true, shiftDown()); else sprite.goTo(target, true, shiftDown()); } }
private void rightMouseClick(int x, int y) { attackMoveClicked = false; GameSprite target = level.getSpriteAt(x, y); for (GameSprite sprite : selected) { if (sprite.onTeam(playerTeam)) { if (target == null) sprite.goTo(x, y, false, shiftDown()); else sprite.goTo(target, false, shiftDown()); } } }
private void leftMouseClick(int x, int y) { if (attackMoveClicked) { attackMoveSelected(x, y); } else { GameSprite sprite = level.getSpriteAt(x, y); if (sprite != null) { selected.clear(); selected.add(sprite); } } }
private void handleInput() { if (input.clicked(0)) leftMouseClick(input.getX(), input.getY()); else if (input.clicked(2)) rightMouseClick(input.getX(), input.getY()); if (input.createdBox()) { ArrayList<GameSprite> boxedSprites = level.getSpritesAt(input.getDragBox()); ArrayList<GameSprite> boxedFriendly = new ArrayList<GameSprite>(); for (GameSprite sprite : boxedSprites) { if (sprite.onTeam(playerTeam)) boxedFriendly.add(sprite); } if (!boxedFriendly.isEmpty()) { selected = boxedFriendly; } } if (input.keyDown(KeyEvent.VK_A)) attackMoveClicked = true; if (input.keyDown(KeyEvent.VK_S)) stopSelected(); if (input.keyDown(KeyEvent.VK_LEFT)) scrollLeft(); if (input.keyDown(KeyEvent.VK_RIGHT)) scrollRight(); if (input.keyDown(KeyEvent.VK_UP)) scrollUp(); if (input.keyDown(KeyEvent.VK_DOWN)) scrollDown(); }
public void render(Graphics g) { level.render(selected, screenX, screenY, g); GUI.render(input, screenX, screenY, g); }
public void tick(Input input) { this.input = input; handleInput(); level.tick(); }