Exemplo n.º 1
0
 public void checkForHit() {
   if (topWall.getTopBounds().intersects(bird.getBounds())
       || bottomWall.getTopBounds().intersects(bird.getBounds())
       || topWall.getBottomBounds().intersects(bird.getBounds())
       || bottomWall.getBottomBounds().intersects(bird.getBounds())
       || bird.getBounds().intersects(new Rectangle2D.Double(0, 600, 800, 10))) {
     isDead = true;
   }
 }
Exemplo n.º 2
0
 public boolean hitWall(Wall w) {
   if (this.isLive() && this.getRect().intersects(w.getRect())) {
     this.live = false;
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
  @Test
  public void usage() {
    HouseBuilder.Start<Void> houseBuilder = HouseGenerator.create(new HouseHelperImpl());

    Wall wall1 = houseBuilder.addWall().setWidth(120.35).setColor(Color.RED);

    Wall wall2 = houseBuilder.addWall().setColor(Color.BLACK).setWidth(87.45);

    Wall wall3 = houseBuilder.addWall().setColor(Color.BLACK).setWidth(80.25);
    wall3.isWeightBearing(true); // this method isn't on the builder

    AffordableHouse option1 = houseBuilder.constructAffordableHouse();
    ExpensiveHouse option2 = houseBuilder.constructExpensiveHouse();

    System.out.println(getInfo(option1));
    System.out.println();
    System.out.println(getInfo(option2));
  }
Exemplo n.º 4
0
  public void render(Wall wall) {
    Stroke stroke = graphics.getStroke();
    graphics.setStroke(new BasicStroke(10));
    Vector from = wall.from().add(viewPoint);
    Vector to = wall.to().add(viewPoint);
    graphics.drawLine((int) from.x(), (int) from.y(), (int) to.x(), (int) to.y());
    graphics.setStroke(stroke);

    if (showWallNormals) {
      Vector centre = wall.centre().add(viewPoint);
      Vector normal = wall.normal();
      int x = (int) centre.x();
      int y = (int) centre.y();
      int toX = x + (int) (normal.x() * 10);
      int toY = y + (int) (normal.y() * 10);
      graphics.drawLine(x, y, toX, toY);
    }
  }
Exemplo n.º 5
0
 public boolean hitWall(Wall w) {
   if (this.getRec().intersects(w.getRec())) {
     /*this.x = iOldX;
     this.y = iOldY;*/
     tc.missiles.remove(this);
     this.bLive = false;
     return true;
   }
   return false;
 }
Exemplo n.º 6
0
 @Override
 public void paintComponent(Graphics g) {
   g.setColor(Color.WHITE);
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   if (isDead) {
     g2.setColor(Color.BLACK);
     g2.setFont(new Font("Serif", Font.PLAIN, 30));
     g2.drawString("Game Over!", 300, 300);
     g2.drawString("Your final score was " + score, 250, 330);
     moverTimer.stop();
     scoreTimer.stop();
   } else {
     topWall.paint(g2);
     bottomWall.paint(g2);
     bird.paint(g2);
     g2.setColor(Color.BLACK);
     g2.setFont(new Font("Serif", Font.PLAIN, 20));
     g2.drawString("Score: " + score, 50, 50);
   }
 }
Exemplo n.º 7
0
 public void produce(double x, double y) {
   Wall tmp = new Wall(x, y);
   tmp.init(units, tower, grid, weapons, effects);
   tower.add(tmp);
 }
Exemplo n.º 8
0
 /** add a control point */
 public void addPoint(Point p) {
   if (pts2d.size() < 4) {
     super.addPoint(p);
   }
 }