Exemple #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();
    }
  }
Exemple #2
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();
   }
 }