public void moveEnemyProjectile() {
    // For ALL projectiles, increase their y value
    for (int i = 0; i < projectileAmount; i++) {
      if (enemyProj[i].isVisible()) {
        // if it has been shot

        enemyProj[i].setPositionY(enemyProj[i].getPositionY() + 5);

        enemyProj[i].setLocation(enemyProjX[i], enemyProj[i].getPositionY());

        checkForHit();
        // Check for hit after it has been moved

        // This is to prevent spawn camping, while the player is
        // respawning (not visible)
        // then the shots will break on the shield
        if (!player.isVisible()) {
          if (enemyProj[i].getPositionY() > shield.getLocation().getY()) {
            enemyProj[i].setVisible(false);
          }

        } else {
          if (enemyProj[i].getPositionY() > 755) {
            enemyProj[i].setVisible(false);
          }
        }
      }
    }
  }
Пример #2
0
 public void mouseDragged(MouseEvent e) {
   gameCursorLabel.setLocation(e.getX() - XFUDGE, e.getY() - YFUDGE);
   hitBox.setLocation(gameCursorLabel.getLocation());
   menuCursorLabel.setLocation(e.getX(), e.getY());
   for (int i = 0; i < aLabel.size(); i++)
     sendCursorLocation(aLabel.get(i)); // Tells certain bugs where you are
 }
 public void checkForLoss() {
   // I made thereAreInvaders() after
   if (thereAreInvaders()) {
     if (getLowerMost().getPositionY() + getLowerMost().getIcon().getIconHeight()
         > shield.getLocation().getY() + 5) {
       // gay
       // ^ Remi wrote that
       loss();
     }
   }
 }
Пример #4
0
    @Override
    public void mouseMoved(MouseEvent e) {
      Point p = e.getPoint();
      Point l = node.getLocation();
      Dimension d = node.getSize();

      if (l.x <= p.x && l.y <= p.y && l.x + d.width >= p.x && l.y + d.height >= p.y) {
        tipLabel.setText(tooltip);
      }
      parent.repaint();
    }
Пример #5
0
 public void mouseMoved(MouseEvent e) {
   gameCursorLabel.setLocation(e.getX() - XFUDGE, e.getY() - YFUDGE);
   hitBox.setLocation(gameCursorLabel.getLocation());
   menuCursorLabel.setLocation(e.getX(), e.getY());
   for (int i = 0; i < aLabel.size(); i++)
     sendCursorLocation(aLabel.get(i)); // Tells certain bugs where you are
   if (onTitleScreen) { // When game is not running, the cursors are directly on pointer
     // Checks if mouse is over a box
     if ((e.getX() >= 55 && e.getX() <= 55 + 54 && e.getY() >= 695 && e.getY() <= 695 + 61)
         || (e.getX() >= 725 && e.getX() <= 725 + 54 && e.getY() >= 695 && e.getY() <= 695 + 61))
       rainbowCursorAnimation();
     else menuCursorLabelAnimating = false;
   }
 }
  /**
   * The run method of this Timer Task The bots tend to follow the character of the user wherever it
   * go. When the user's char is on the opposite floor, the bots will go to the portal(door) leading
   * to the same floor where the character is If the character and the bots are on the same floor,
   * the bots will go to the direction where the user's character is. The effect of the fighting or
   * pushing of the user's character is also defined here. With the user of bare hand, the user's
   * push to the bots is stronger but of limited range. On the other side, with the use of the gun,
   * the user's range is wide but the push is weak
   */
  public void run() {

    movementCount++;

    movementIndex++;
    movementIndex = movementIndex % Archers.frameCount;
    if (movementIndex % movementFactor == 0) {

      if (temp == 0) {
        botLabel.setLocation(
            (int) botLabel.getLocation().getX(),
            (int) botLabel.getLocation().getY() - (movementFactor * 3));
        botLabel.setIcon(
            new ImageIcon(
                Toolkit.getDefaultToolkit()
                    .createImage(
                        Archers.getBufferedImageArray(Archers.bot_NORTH)[movementIndex]
                            .getSource())));
        if ((int) botLabel.getLocation().getY() <= 0) temp = 1; // botLabel.setIcon(null);

        // botLabel.setBounds(1000, 440, 115, 144);

      } else if (temp == 1) {
        botLabel.setLocation(
            (int) botLabel.getLocation().getX(),
            (int) botLabel.getLocation().getY() + (movementFactor * 3));
        botLabel.setIcon(
            new ImageIcon(
                Toolkit.getDefaultToolkit()
                    .createImage(
                        Archers.getBufferedImageArray(Archers.bot_SOUTH)[movementIndex]
                            .getSource())));
        if ((int) botLabel.getLocation().getY() >= 400) temp = 0;
      }
    }
  }
  public void moveProjectile() {
    // if the player's shot exists
    if (playerProj.isVisible()) {
      playerProj.setPositionY(playerProj.getPositionY() - 5);
      // Move it down (higher edge of the screen)
      playerProj.setLocation(playerProjX, playerProj.getPositionY());
      // Check for hit
      checkForHit();
    }

    if (playerProj.getPositionY() <= ceiling.getLocation().getY() + 5) {
      playerProj.setVisible(false);
    }
    checkForHit();
  }