Package rectangles

Examples of rectangles.CrateRectangle


    this.map = map;
    player = map.getPlayers().getFirst();
    location = p;
    health = 1;// one shot death
    // 25 is to offset for the size so it's not off the field
    rect = new CrateRectangle(location.col - 25, location.row - 25);
  }
View Full Code Here


   *            damage that will be done to the crate
   */
  public void recieveDamage(int dmg) {
    health = health - dmg;
    if (this.removeObstacle()) {
      rect = new CrateRectangle(-1, -1);// removing off field
      map.getObstacles().remove(this);
    }

  }
View Full Code Here

    LinkedList<PlayerTank> players = map.getPlayers();
    LinkedList<EnemyTank> enemies = map.getEnemies();

    if (d == Direction.EAST) {
      location = new Point(location.row, location.col + player.getSpeed());
      rect = new CrateRectangle(location.col - 25, location.row - 25);
      for (int i = 0; i < players.size(); i++) {
        PlayerTank p = players.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row, location.col
              - player.getSpeed());
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < enemies.size(); i++) {
        EnemyTank p = enemies.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row, location.col
              - player.getSpeed());
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < obs.size(); i++) {
        Obstacle o = obs.get(i);
        if (o instanceof ImmovableBlock) {
          if (((ImmovableBlock) o).getRectangle().intersects(rect)) {
            location = new Point(location.row, location.col
                - player.getSpeed());
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof TNT) {
          if (((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row, location.col
                - player.getSpeed());
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof SpikePit) {
          if (((SpikePit) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
          }
        }
        if (o instanceof Crate) {
          if (o != this) {
            if (((Crate) o).getRectangle().intersects(rect)) {
              location = new Point(location.row, location.col
                  - player.getSpeed());
              rect = new CrateRectangle(location.col - 25,
                  location.row - 25);
              return false;
            }
          }
        }
        if (o instanceof FireRing) {
          if (((FireRing) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
            break;
          }
        }
      }
      if (location.col > 955) {
        location = new Point(location.row, location.col
            - player.getSpeed());
        rect = new CrateRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveCrate");
      setChanged();

    }
    if (d == Direction.WEST) {
      location = new Point(location.row, location.col - player.getSpeed());
      rect = new CrateRectangle(location.col - 25, location.row - 25);
      for (int i = 0; i < players.size(); i++) {
        PlayerTank p = players.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row, location.col
              + player.getSpeed());
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < enemies.size(); i++) {
        EnemyTank p = enemies.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row, location.col
              + player.getSpeed());
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < obs.size(); i++) {
        Obstacle o = obs.get(i);
        if (o instanceof ImmovableBlock) {
          if (((ImmovableBlock) o).getRectangle().intersects(rect)) {
            location = new Point(location.row, location.col
                + player.getSpeed());
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof TNT) {
          if (((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row, location.col
                + player.getSpeed());
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof Crate) {
          if (o != this) {
            if (((Crate) o).getRectangle().intersects(rect)) {
              location = new Point(location.row, location.col
                  + player.getSpeed());
              rect = new CrateRectangle(location.col - 25,
                  location.row - 25);
              return false;
            }
          }
        }
        if (o instanceof SpikePit) {
          if (((SpikePit) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
          }
        }
        if (o instanceof FireRing) {
          if (((FireRing) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
            break;
          }
        }
      }
      if (location.col < 30) {
        location = new Point(location.row, location.col
            + player.getSpeed());
        rect = new CrateRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveCrate");
      setChanged();

    }
    if (d == Direction.NORTH) {
      location = new Point(location.row - player.getSpeed(), location.col);
      rect = new CrateRectangle(location.col - 25, location.row - 25);
      for (int i = 0; i < players.size(); i++) {
        PlayerTank p = players.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row + player.getSpeed(),
              location.col);
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < enemies.size(); i++) {
        EnemyTank p = enemies.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row + player.getSpeed(),
              location.col);
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < obs.size(); i++) {
        Obstacle o = obs.get(i);
        if (o instanceof ImmovableBlock) {
          if (((ImmovableBlock) o).getRectangle().intersects(rect)) {
            location = new Point(location.row + player.getSpeed(),
                location.col);
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof TNT) {
          if (((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row + player.getSpeed(),
                location.col);
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof Crate) {
          if (o != this) {
            if (((Crate) o).getRectangle().intersects(rect)) {
              location = new Point(location.row
                  + player.getSpeed(), location.col);
              rect = new CrateRectangle(location.col - 25,
                  location.row - 25);
              return false;
            }
          }
        }
        if (o instanceof SpikePit) {
          if (((SpikePit) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);

          }
        }
        if (o instanceof FireRing) {
          if (((FireRing) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
            break;
          }
        }
      }
      if (location.row < 30) {
        location = new Point(location.row + player.getSpeed(),
            location.col);
        rect = new CrateRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveCrate");
      setChanged();

    }
    if (d == Direction.SOUTH) {
      location = new Point(location.row + player.getSpeed(), location.col);
      rect = new CrateRectangle(location.col - 25, location.row - 25);
      for (int i = 0; i < players.size(); i++) {
        PlayerTank p = players.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row - player.getSpeed(),
              location.col);
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < enemies.size(); i++) {
        EnemyTank p = enemies.get(i);
        if (p.getRectangle().intersects(rect)) {
          location = new Point(location.row - player.getSpeed(),
              location.col);
          rect = new CrateRectangle(location.col - 25,
              location.row - 25);
          return false;
        }
      }
      for (int i = 0; i < obs.size(); i++) {
        Obstacle o = obs.get(i);
        if (o instanceof ImmovableBlock) {
          if (((ImmovableBlock) o).getRectangle().intersects(rect)) {
            location = new Point(location.row - player.getSpeed(),
                location.col);
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof TNT) {
          if (((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row - player.getSpeed(),
                location.col);
            rect = new CrateRectangle(location.col - 25,
                location.row - 25);
            return false;
          }
        }
        if (o instanceof Crate) {
          if (o != this) {
            if (((Crate) o).getRectangle().intersects(rect)) {
              location = new Point(location.row
                  - player.getSpeed(), location.col);
              rect = new CrateRectangle(location.col - 25,
                  location.row - 25);
              return false;
            }
          }
        }
        if (o instanceof SpikePit) {
          if (((SpikePit) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
            notifyObservers(new Point(location.row - 12,
                location.col - 12));
            setChanged();
          }
        }
        if (o instanceof FireRing) {
          if (((FireRing) o).getRectangle().intersects(rect)) {
            this.recieveDamage(1);
            break;
          }
        }
      }
      if (location.row > 665) {
        location = new Point(location.row - player.getSpeed(),
            location.col);
        rect = new CrateRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveCrate");
      setChanged();
View Full Code Here

    for (int i = 0; i < obstacleList.size(); i++) {
      Obstacle p = obstacleList.get(i);

      if (p instanceof Crate) {// for instance of crate
        Crate c = (Crate) p;
        CrateRectangle cRect = c.getRectangle();
        g.drawImage(cRect.getImage(), cRect.xCoord(), cRect.yCoord(),
            null);
      }
      if (p instanceof ImmovableBlock) {// for instance of immovableBlock
        ImmovableBlock ib = (ImmovableBlock) p;
        ImmovableBlockRectangle ibRect = ib.getRectangle();
View Full Code Here

    }
    for (int i = 0; i < obs.size(); i++) {
      Obstacle p = obs.get(i);
      if (p instanceof Crate) {// for instance of crate
        Crate c = (Crate) p;
        CrateRectangle tRect = c.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof ImmovableBlock) {// for instance of immovableBlock
        ImmovableBlock ib = (ImmovableBlock) p;
        ImmovableBlockRectangle tRect = ib.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof SpikePit) {// for instance of SpikePit
        SpikePit sp = (SpikePit) p;
        SpikePitRectangle tRect = sp.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof FireRing) {// for instance of fireRing
        FireRing fr = (FireRing) p;
        FireRingRectangle tRect = fr.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tRect = tnt.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
View Full Code Here

    }
    for (int i = 0; i < obs.size(); i++) {
      Obstacle p = obs.get(i);
      if (p instanceof Crate) {// for instance of crate
        Crate c = (Crate) p;
        CrateRectangle tRect = c.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof ImmovableBlock) {// for instance of immovableBlock
        ImmovableBlock ib = (ImmovableBlock) p;
        ImmovableBlockRectangle tRect = ib.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof SpikePit) {// for instance of SpikePit
        SpikePit sp = (SpikePit) p;
        SpikePitRectangle tRect = sp.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof FireRing) {// for instance of fireRing
        FireRing fr = (FireRing) p;
        FireRingRectangle tRect = fr.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tRect = tnt.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
View Full Code Here

    }
    for (int i = 0; i < obs.size(); i++) {
      Obstacle p = obs.get(i);
      if (p instanceof Crate) {// for instance of crate
        Crate c = (Crate) p;
        CrateRectangle tRect = c.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof ImmovableBlock) {// for instance of immovableBlock
        ImmovableBlock ib = (ImmovableBlock) p;
        ImmovableBlockRectangle tRect = ib.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof SpikePit) {// for instance of SpikePit
        SpikePit sp = (SpikePit) p;
        SpikePitRectangle tRect = sp.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof FireRing) {// for instance of fireRing
        FireRing fr = (FireRing) p;
        FireRingRectangle tRect = fr.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tRect = tnt.getRectangle();
        if(tRect.intersects(rect)) {
          return false;
        }
       
      }
View Full Code Here

        g.drawImage(spRect.getImage(), spRect.xCoord(),
            spRect.yCoord(), null);
      }
      if (p instanceof Crate) {// for instance of crate
        Crate c = (Crate) p;
        CrateRectangle cRect = c.getRectangle();
        g.drawImage(cRect.getImage(), cRect.xCoord(), cRect.yCoord(),
            null);
       
      }
      if (p instanceof ImmovableBlock) {// for instance of immovableBlock
        ImmovableBlock ib = (ImmovableBlock) p;
View Full Code Here

    this.map = map;
    player = map.getPlayers().getFirst();
    location = p;
    health = 1;// one shot death
    // 25 is to offset for the size so it's not off the field
    rect = new CrateRectangle(location.col - 25, location.row - 25);
  }
View Full Code Here

   *            damage that will be done to the crate
   */
  public void recieveDamage(int dmg) {
    health = health - dmg;
    if (this.removeObstacle()) {
      rect = new CrateRectangle(-1, -1);// removing off field
      map.getObstacles().remove(this);
    }

  }
View Full Code Here

TOP

Related Classes of rectangles.CrateRectangle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.