Esempio n. 1
0
  private void shipCrash(Ball ball) {

    ArrayList<Integer> lr = getPointListUp(ball.getRadio(), ball.getXC(), ball.getYC());
    int r2 = (int) Math.pow(ball.getRadio(), 2);

    if (lr.contains(r2) && ball.getDY() >= 0) {
      ball.setDY(ball.getDY() * -1);
      ball.setAllFirst();
    }
  }
Esempio n. 2
0
  private void verifyCrashes() {
    borderCrash(ball);

    // CRASHES TO THE SHIPBALL FALLING DOWN
    if ((ball.getYC() + ball.getRadio()) >= ship.sideY1 && ball.getDY() >= 0) {
      ship.shipCrash(ball);
    }
    // CRASHES TO THE WALL  WITH BALL
    boolean cmpSideY2 = (ball.getYC() - ball.getRadio()) <= wall.sideY2 && ball.getDY() <= 0;
    boolean cmpSideY1 = (ball.getYC() + ball.getRadio()) >= wall.sideY1 && ball.getDY() >= 0;
    if (cmpSideY1 || cmpSideY2) {
      wall.blockListCrashes(ball);
    }
  }
Esempio n. 3
0
 private void borderCrash(Ball ball) {
   if (ball.getYC() <= 57 && ball.getDY() < 0) {
     ball.setDY(ball.getDY() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
   if (ball.getYC() >= (height - 36) && ball.getDY() > 0) {
     ball.setDY(ball.getDY() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
   if (ball.getXC() <= 36 && ball.getDX() < 0) {
     ball.setDX(ball.getDX() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
   if (ball.getXC() >= (width - 11) && ball.getDX() > 0) {
     ball.setDX(ball.getDX() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
 }