Package rectangles

Examples of rectangles.TNTRectangle


    this.map = map;
    player = map.getPlayers().getFirst();
    location = p;
    health = 1;// TNT starts with 1 health
    // 25 is to offset for the size so it's not off the field
    rect = new TNTRectangle(location.col - 25, location.row - 25);

  }
View Full Code Here


   *            damage that will be done to the TNT
   */
  public void recieveDamage(int dmg) {
    health = health - dmg;
    if (this.removeObstacle()) {
      rect = new TNTRectangle(-100, -100);// removing off field
      BlastRadiusRectangle b = new BlastRadiusRectangle(location.col - 50, location.row - 50);
      LinkedList<Obstacle> obs = map.getObstacles();
      LinkedList<PlayerTank> tank = map.getPlayers();
      LinkedList<EnemyTank> enemies = map.getEnemies();
      for(int i = 0; i < obs.size(); i++) {
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 TNTRectangle(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 TNTRectangle(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 TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
            return false;
          }
        }
        if(o instanceof TNT) {
          if(o != this) {
          if(((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row, location.col - player.getSpeed());
            rect = new TNTRectangle(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 TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveTNT");
      setChanged();
      return true;
     
    }
    if(d == Direction.WEST) {
      location = new Point(location.row, location.col - player.getSpeed());
      rect = new TNTRectangle(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 TNTRectangle(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 TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
            return false;
          }
        }
        if(o instanceof TNT) {
          if(o != this) {
          if(((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row, location.col + player.getSpeed());
            rect = new TNTRectangle(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 TNTRectangle(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 < 30) {
        location = new Point(location.row, location.col + player.getSpeed());
        rect = new TNTRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveTNT");
      setChanged();
      return true;
     
    }
    if(d == Direction.NORTH) {
      location = new Point(location.row - player.getSpeed(), location.col);
      rect = new TNTRectangle(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 TNTRectangle(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 TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
            return false;
          }
        }
        if(o instanceof TNT) {
          if(o != this) {
          if(((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row + player.getSpeed(), location.col);
            rect = new TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
            return false;
          }
          }
        }
        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 TNTRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveTNT");
      setChanged();
      return true;
 
    }
    if(d == Direction.SOUTH) {
      location = new Point(location.row + player.getSpeed(), location.col);
      rect = new TNTRectangle(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 TNTRectangle(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 TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
            return false;
          }
        }
        if(o instanceof TNT) {
          if(o != this) {
          if(((TNT) o).getRectangle().intersects(rect)) {
            location = new Point(location.row - player.getSpeed(), location.col);
            rect = new TNTRectangle(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 TNTRectangle(location.col - 25, location.row - 25);
            return false;
          }
          }
        }
        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 TNTRectangle(location.col - 25, location.row - 25);
        return false;
      }
      notifyObservers("moveTNT");
      setChanged();
      return true;
View Full Code Here

        g.drawImage(fr.getImage(), frRect.xCoord(), frRect.yCoord(),
            null);
      }
      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tntRect = tnt.getRectangle();
        g.drawImage(tntRect.getImage(), tntRect.xCoord(),
            tntRect.yCoord(), null);
      }

    }
    for (PlayerTank p : tankList) {
      TankRectangle tRect = p.getRectangle();
View Full Code Here

      }
     

      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tntRect = tnt.getRectangle();
        g.drawImage(tntRect.getImage(), tntRect.xCoord(),
            tntRect.yCoord(), null);
     
      }

    }
    for (PlayerTank p : tankList) {
View Full Code Here

        }
       
      }
      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

        }
       
      }
      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

        }
       
      }
      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(fr.getImage(), frRect.xCoord(), frRect.yCoord(),
            null);
      }
      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tntRect = tnt.getRectangle();
        g.drawImage(tntRect.getImage(), tntRect.xCoord(),
            tntRect.yCoord(), null);
      }

    }
    for (PlayerTank p : tankList) {
      TankRectangle tRect = p.getRectangle();
View Full Code Here

    this.map = map;
    player = map.getPlayers().getFirst();
    location = p;
    health = 1;// TNT starts with 1 health
    // 25 is to offset for the size so it's not off the field
    rect = new TNTRectangle(location.col - 25, location.row - 25);

  }
View Full Code Here

TOP

Related Classes of rectangles.TNTRectangle

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.